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 951593427538cd5f08dee6ff8b72b1d90efb336f..1e0eec36e5c1966612ac5342183bc2ea6524fe45 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 @@ -14,6 +14,7 @@ class SourceContext DEFAULT_SECURE_FILES_PATH = 'ci_secure_files/' DEFAULT_CI_LFS_PATH = 'lfs-objects/' DEFAULT_PACKAGES = 'packages/' + DEFAULT_PAGES = 'pages/' def gitlab_version File.read(gitlab_basepath.join("VERSION")).strip.freeze @@ -67,8 +68,10 @@ def packages_path # GitLab Pages basepath def pages_path - # TODO: Use configuration solver - Gitlab.config.pages.path + path = gitlab_config.dig(env, 'pages', 'path') || + gitlab_shared_path.join(DEFAULT_PAGES) + + absolute_path(path) end # Registry basepath diff --git a/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml b/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml index fb754ccf649a93fa53802766c67a678d97f44111..63178d4ec677a0a31e44c9af5d110f7df0c9d3cd 100644 --- a/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml +++ b/gems/gitlab-backup-cli/spec/fixtures/gitlab.yml @@ -119,7 +119,7 @@ test: # your system username you use to run GitLab # user: YOUR_USERNAME pages: - path: tmp/tests/pages + path: /tmp/gitlab/full/pages object_store: enabled: false remote_directory: pages # The bucket name @@ -130,7 +130,7 @@ test: region: us-east-1 local_store: enabled: true - path: tmp/tests/pages + path: /tmp/gitlab/full/pages repositories: storages: default: 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 1af52add44165cc2ebb5870377b975e4caddfa85..f57e42d141ab3348a62ac17bbd6e5c30c181a1cf 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 @@ -173,6 +173,32 @@ end end + describe '#pages_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.pages_path).to eq(fake_gitlab_basepath.join('test-shared/pages')) + 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.pages_path).to eq(fake_gitlab_basepath.join('tmp/tests/pages')) + 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.pages_path).to eq(Pathname('/tmp/gitlab/full/pages')) + end + end + end + describe '#gitlab_shared_path' do context 'with shared path not configured in gitlab.yml' do it 'raises an error' do