diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb index 30c47322e59669e48f8f2e40e234c26667f830b2..e6d08533664c2f22e41b5b1379319a32c422984c 100644 --- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb +++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb @@ -11,6 +11,7 @@ class SourceContext # Defaults defined in `config/initializers/1_settings.rb` DEFAULT_CI_BUILDS_PATH = 'builds/' DEFAULT_JOBS_ARTIFACTS_PATH = 'artifacts/' + DEFAULT_SECURE_FILES_PATH = 'ci_secure_files/' def gitlab_version File.read(gitlab_basepath.join("VERSION")).strip.freeze @@ -40,8 +41,10 @@ def ci_job_artifacts_path # CI Secure Files basepath def ci_secure_files_path - # TODO: Use configuration solver - Settings.ci_secure_files.storage_path + path = gitlab_config.dig(env, 'ci_secure_files', 'storage_path') || + gitlab_shared_path.join(DEFAULT_SECURE_FILES_PATH) + + absolute_path(path) end # CI LFS basepath diff --git a/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml b/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml index 42b8cd0080cfb4de07a4e6b940701aec130bffde..8a25656b7a3aca4e9ad035575007f7b81a390cde 100644 --- a/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml +++ b/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml @@ -76,7 +76,7 @@ test: ci_secure_files: enabled: true - storage_path: tmp/tests/ci_secure_files + storage_path: /tmp/gitlab/full/ci_secure_files object_store: enabled: false remote_directory: ci-secure-files diff --git a/gems/gitlab-backup-cli/spec/gitlab/backup/cli/source_context_spec.rb b/gems/gitlab-backup-cli/spec/gitlab/backup/cli/source_context_spec.rb index 3cc58c1962cba3ce38445806581293d3a534e6f8..65dbb6ce45d6d7186bbef6a610fa38577a228a51 100644 --- a/gems/gitlab-backup-cli/spec/gitlab/backup/cli/source_context_spec.rb +++ b/gems/gitlab-backup-cli/spec/gitlab/backup/cli/source_context_spec.rb @@ -95,6 +95,32 @@ end end + describe '#ci_secure_files_path' do + context 'with a missing configuration value' do + it 'returns the default value in full path' do + use_gitlab_config_fixture('gitlab-missingconfigs.yml') + + expect(context.ci_secure_files_path).to eq(fake_gitlab_basepath.join('test-shared/ci_secure_files')) + end + end + + context 'with a relative path configured in gitlab.yml' do + it 'returns a full path based on gitlab basepath' do + use_gitlab_config_fixture('gitlab-relativepaths.yml') + + expect(context.ci_secure_files_path).to eq(fake_gitlab_basepath.join('tmp/tests/ci_secure_files')) + end + end + + context 'with a full path configured in gitlab.yml' do + it 'returns a full path as configured in gitlab.yml' do + use_gitlab_config_fixture('gitlab.yml') + + expect(context.ci_secure_files_path).to eq(Pathname('/tmp/gitlab/full/ci_secure_files')) + end + end + end + describe '#gitlab_shared_path' do context 'with shared path not configured in gitlab.yml' do it 'raises an error' do