Skip to content
Snippets Groups Projects
Unverified Commit b9144d23 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Remove old git_data_dirs syntax.

Rubocop
parent b98eb233
No related branches found
No related tags found
1 merge request!1913Resolve "Remove support for deprecated git_data_dir setting structure"
Loading
Loading
@@ -28,22 +28,17 @@ module GitlabShell
end
 
def parse_git_data_dirs
# Make sure we inform the user that they are using configuration that is
# not supported.
raise 'Encountered unsupported config key \'git_data_dir\' in /etc/gitlab/gitlab.rb.' if Gitlab['git_data_dir']
git_data_dirs = Gitlab['git_data_dirs']
return unless git_data_dirs.any?
gitaly_address = Gitaly.gitaly_address
git_data_dirs.select{ |k,v| raise 'Unsupported configuration detected in \'git_data_dirs\' in /etc/gitlab/gitlab.rb.' if v.is_a?(String)}
 
Gitlab['gitlab_shell']['git_data_directories'] ||=
if git_data_dirs.any?
Hash[git_data_dirs.map do |name, data_directory|
if data_directory.is_a?(String)
Chef::Log.warn "Your git_data_dirs settings are deprecated. Please refer to https://docs.gitlab.com/omnibus/settings/configuration.html#storing-git-data-in-an-alternative-directory for updated documentation."
[name, { 'path' => data_directory }]
else
[name, data_directory]
end
end]
end
gitaly_address = Gitaly.gitaly_address
 
Gitlab['gitlab_shell']['git_data_directories'] ||= git_data_dirs
Gitlab['gitlab_rails']['repositories_storages'] ||=
Hash[Gitlab['gitlab_shell']['git_data_directories'].map do |name, data_directory|
shard_gitaly_address = data_directory['gitaly_address'] || gitaly_address
Loading
Loading
Loading
Loading
@@ -205,8 +205,24 @@ describe 'gitlab_shell::git_data_dirs' do
allow(Gitlab).to receive(:[]).and_call_original
end
 
context 'when using invalid old git_data_dir configuration' do
before { stub_gitlab_rb(git_data_dir: '/tmp/user/git-data') }
it 'exception is raised' do
expect { chef_run }.to raise_exception('Encountered unsupported config key \'git_data_dir\' in /etc/gitlab/gitlab.rb.')
end
end
context 'when using invalid old git_data_dirs configuration' do
before { stub_gitlab_rb(git_data_dirs: { 'default' => '/tmp/user/git-data' }) }
it 'exception is raised' do
expect { chef_run }.to raise_exception('Unsupported configuration detected in \'git_data_dirs\' in /etc/gitlab/gitlab.rb.')
end
end
context 'when gitaly is set to use a listen_addr instead of a socket' do
before { stub_gitlab_rb(git_data_dir: '/tmp/user/git-data', gitaly: { socket_path: '', listen_addr: 'localhost:8123' }) }
before { stub_gitlab_rb(git_data_dirs: { 'default' => { 'path' => '/tmp/user/git-data' } }, gitaly: { socket_path: '', listen_addr: 'localhost:8123' }) }
 
it 'correctly sets the repository storage directories' do
expect(chef_run.node['gitlab']['gitlab-rails']['repositories_storages'])
Loading
Loading
@@ -256,42 +272,4 @@ describe 'gitlab_shell::git_data_dirs' do
})
end
end
context 'when git_data_dirs is set with deprecated settings structure' do
before do
stub_gitlab_rb({
git_data_dirs: {
'default' => '/tmp/default/git-data',
'overflow' => '/tmp/other/git-overflow-data'
}
})
end
it 'correctly sets the shell git data directories' do
# Allow warn to be called for other messages without failing the test
allow(Chef::Log).to receive(:warn)
expect(Chef::Log).to receive(:warn).with("Your git_data_dirs settings are deprecated. Please refer to https://docs.gitlab.com/omnibus/settings/configuration.html#storing-git-data-in-an-alternative-directory for updated documentation.")
expect(chef_run.node['gitlab']['gitlab-shell']['git_data_directories']).to eql({
'default' => { 'path' => '/tmp/default/git-data' },
'overflow' => { 'path' => '/tmp/other/git-overflow-data' }
})
end
it 'correctly sets the repository storage directories' do
expect(chef_run.node['gitlab']['gitlab-rails']['repositories_storages']).to eql({
'default' => { 'path' => '/tmp/default/git-data/repositories', 'gitaly_address' => 'unix:/var/opt/gitlab/gitaly/gitaly.socket' },
'overflow' => { 'path' => '/tmp/other/git-overflow-data/repositories', 'gitaly_address' => 'unix:/var/opt/gitlab/gitaly/gitaly.socket' }
})
end
end
it 'defaults the auth_file to be within the user\'s home directory' do
stub_gitlab_rb(user: { home: '/tmp/user' })
expect(chef_run.node['gitlab']['gitlab-shell']['auth_file']).to eq('/tmp/user/.ssh/authorized_keys')
end
it 'uses custom auth_files set in gitlab.rb' do
stub_gitlab_rb(user: { home: '/tmp/user' }, gitlab_shell: { auth_file: '/tmp/authorized_keys' })
expect(chef_run.node['gitlab']['gitlab-shell']['auth_file']).to eq('/tmp/authorized_keys')
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment