Merge branch 'add_home_workhorse' into 'master'

Add default HOME variable to workhorse

Closes https://gitlab.com/gitlab-org/gitlab-workhorse/issues/58

See merge request !995
This commit is contained in:
Marin Jankovski 2016-09-16 08:55:10 +00:00
commit fcfa367221
4 changed files with 43 additions and 1 deletions

View File

@ -17,6 +17,7 @@ omnibus-gitlab repository.
- Use single db_host when multi postgresql::listen_adresses
- Add gitlab-ctl registry-garbage-collect command
- Update curl to version 7.50.3
- Add default HOME variable to workhorse
8.11.6

View File

@ -457,7 +457,8 @@ default['gitlab']['gitlab-workhorse']['dir'] = "/var/opt/gitlab/gitlab-workhorse
default['gitlab']['gitlab-workhorse']['log_directory'] = "/var/log/gitlab/gitlab-workhorse"
default['gitlab']['gitlab-workhorse']['proxy_headers_timeout'] = nil
default['gitlab']['gitlab-workhorse']['env'] = {
'PATH' => "#{node['package']['install-dir']}/bin:#{node['package']['install-dir']}/embedded/bin:/bin:/usr/bin"
'PATH' => "#{node['package']['install-dir']}/bin:#{node['package']['install-dir']}/embedded/bin:/bin:/usr/bin",
'HOME' => node['gitlab']['user']['home']
}
####

View File

@ -0,0 +1,28 @@
require 'chef_helper'
describe 'gitlab::gitlab-workhorse' do
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
before do
allow(Gitlab).to receive(:[]).and_call_original
# Prevent chef converge from reloading the helper library, which would override our helper stub
allow(Kernel).to receive(:load).and_call_original
allow(Kernel).to receive(:load).with(%r{gitlab/libraries/storage_directory_helper}).and_return(true)
end
context 'with environment variables' do
context 'by default' do
it_behaves_like "enabled gitlab-workhorse env", "HOME", '\/var\/opt\/gitlab'
it_behaves_like "enabled gitlab-workhorse env", "PATH", '\/opt\/gitlab\/bin:\/opt\/gitlab\/embedded\/bin:\/bin:\/usr\/bin'
context 'when a custom env variable is specified' do
before do
stub_gitlab_rb(gitlab_workhorse: { env: { 'IAM' => 'CUSTOMVAR'}})
end
it_behaves_like "enabled gitlab-workhorse env", "IAM", 'CUSTOMVAR'
end
end
end
end

View File

@ -21,3 +21,15 @@ shared_examples 'disabled gitlab-rails env' do |env_var, content|
)
end
end
shared_examples 'enabled gitlab-workhorse env' do |env_var, content|
it 'created env directory' do
expect(chef_run).to create_directory("/opt/gitlab/etc/gitlab-workhorse/env")
end
it "does create the #{env_var} file" do
expect(chef_run).to create_file("/opt/gitlab/etc/gitlab-workhorse/env/#{env_var}").with_content(
/#{content}/
)
end
end