Commit 264d785a authored by Kirill Smelkov's avatar Kirill Smelkov

gitlab: Slapos'ify / tweak gitconfig and hook it into the system

Convert gitconfig template to jinja2 (reusing already-there
`email_display_name` and `email_from` parameters for commits generated by
gitlab).

System-level git config from gitlab-omnibus is also imported to this
file (on slapos we cannot tweak system-level git config -
software/.../parts/git/... is read-only for programs in instance
partitions - so we move all gitlab's system-wide git settings to this
"user-level" gitconfig.

System gitconfig in omnibus is defined here:

    https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8eda093/files/gitlab-cookbooks/gitlab/attributes/default.rb#L23

so it is

    pack.threads = 1    and
    receive.fsckObjects = true

which makes sense to not waste a lot of memory when packing and not to
allow corrupt objects to enter to system by evil users intentionally.

To make the file foundable by git - we put it into partition root
directory and set $HOME to point to partition root when running
appropriate programs / services.

NOTE we'll need to upgrade gitlab-shell and gitlab-workhorse to
    propagate $HOME for this setting to actually have effect.
    See the next patch.

/cc @kazuhiko, @jerome
parent 8f945bd2
...@@ -15,6 +15,8 @@ parts = ...@@ -15,6 +15,8 @@ parts =
gitlab-{{ prog }} gitlab-{{ prog }}
{% endfor %} {% endfor %}
gitconfig
gitlab-work gitlab-work
gitlab-shell-work gitlab-shell-work
...@@ -171,6 +173,12 @@ template= {{ database_yml_in }} ...@@ -171,6 +173,12 @@ template= {{ database_yml_in }}
context-extra = context-extra =
section pgsql service-postgresql section pgsql service-postgresql
[gitconfig]
<= etc-template
template= {{ gitconfig_in }}
# NOTE put directly into $HOME/ - this way git will pick it up
rendered= ${directory:home}/.${:_buildout_section_name_}
[gitlab-shell-config.yml] [gitlab-shell-config.yml]
<= etc-template <= etc-template
template= {{ gitlab_shell_config_yml_in }} template= {{ gitlab_shell_config_yml_in }}
...@@ -222,8 +230,10 @@ context-extra = ...@@ -222,8 +230,10 @@ context-extra =
[gitlab-bin] [gitlab-bin]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
wrapper-path = ${directory:bin}/${:_buildout_section_name_} wrapper-path = ${directory:bin}/${:_buildout_section_name_}
# NOTE $HOME needed to pick gitconfig
environment = environment =
BUNDLE_GEMFILE = {{ gitlab_repository_location }}/Gemfile BUNDLE_GEMFILE = {{ gitlab_repository_location }}/Gemfile
HOME = ${directory:home}
RAILS_ENV = production RAILS_ENV = production
# NOTE sys.argv[1:] implicitly appended # NOTE sys.argv[1:] implicitly appended
...@@ -466,8 +476,10 @@ command-line = {{ gitlab_workhorse }} ...@@ -466,8 +476,10 @@ command-line = {{ gitlab_workhorse }}
# NOTE environment for: # NOTE environment for:
# - git to be available on path # - git to be available on path
# - ruby to be available on path (gitlab-workhorse -> gitlab-shell -> hooks on push) # - ruby to be available on path (gitlab-workhorse -> gitlab-shell -> hooks on push)
# - gitconfig be found from ~/.gitconfig
environment = environment =
PATH={{ git_location }}/bin:{{ ruby_location }}/bin:%(PATH)s PATH={{ git_location }}/bin:{{ ruby_location }}/bin:%(PATH)s
HOME=${directory:home}
depend = depend =
${promise-gitlab-workhorse:recipe} ${promise-gitlab-workhorse:recipe}
......
...@@ -47,6 +47,7 @@ context = ...@@ -47,6 +47,7 @@ context =
# config files # config files
raw config_ru_in ${config.ru.in:target} raw config_ru_in ${config.ru.in:target}
raw database_yml_in ${database.yml.in:target} raw database_yml_in ${database.yml.in:target}
raw gitconfig_in ${gitconfig.in:target}
raw gitlab_parameters_cfg ${gitlab-parameters.cfg:target} raw gitlab_parameters_cfg ${gitlab-parameters.cfg:target}
raw gitlab_shell_config_yml_in ${gitlab-shell-config.yml.in:target} raw gitlab_shell_config_yml_in ${gitlab-shell-config.yml.in:target}
raw gitlab_unicorn_startup_in ${gitlab-unicorn-startup.in:target} raw gitlab_unicorn_startup_in ${gitlab-unicorn-startup.in:target}
......
...@@ -196,6 +196,10 @@ url = ${:_profile_base_location_}/template/${:_buildout_section_name_} ...@@ -196,6 +196,10 @@ url = ${:_profile_base_location_}/template/${:_buildout_section_name_}
<= download-template <= download-template
# md5sum = TODO # md5sum = TODO
[gitconfig.in]
<= download-template
# md5sum = TODO
[gitlab-parameters.cfg] [gitlab-parameters.cfg]
<= download-file <= download-file
# md5sum = TODO # md5sum = TODO
......
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
[user]
name = <%= node['gitlab']['user']['git_user_name'] %>
email = <%= node['gitlab']['user']['git_user_email'] %>
[core]
autocrlf = input
{{ autogenerated }}
# global git configuration for GitLab
# see:
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/attributes/default.rb
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/gitconfig.erb
# (last updated for omnibus-gitlab 8.2.3+ce.0-0-g8eda093)
#
{% from 'macrolib.cfg.in' import cfg with context %}
# don't waste memory when packing (each thread uses own work memory)
# besides it packs better with 1 thread
[pack]
threads = 1
# don't allow corrupt/broken objects to go in
[receive]
fsckObjects = true
[user]
name = {{ cfg('email_display_name') }}
email = {{ cfg('email_from') }}
[core]
autocrlf = input
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment