Skip to content
代码片段 群组 项目
提交 5ad263af 编辑于 作者: Gabriel Mazetto's avatar Gabriel Mazetto
浏览文件

Decouple `upload_path` in `SourceContext`

上级 cf1f587d
No related branches found
No related tags found
无相关合并请求
...@@ -17,6 +17,7 @@ class SourceContext ...@@ -17,6 +17,7 @@ class SourceContext
DEFAULT_PAGES = 'pages/' DEFAULT_PAGES = 'pages/'
DEFAULT_REGISTRY_PATH = 'registry/' DEFAULT_REGISTRY_PATH = 'registry/'
DEFAULT_TERRAFORM_STATE_PATH = 'terraform_state/' DEFAULT_TERRAFORM_STATE_PATH = 'terraform_state/'
DEFAULT_UPLOADS_PATH = 'public/' # based on GitLab's root folder
def gitlab_version def gitlab_version
File.read(gitlab_basepath.join("VERSION")).strip.freeze File.read(gitlab_basepath.join("VERSION")).strip.freeze
...@@ -94,8 +95,10 @@ def terraform_state_path ...@@ -94,8 +95,10 @@ def terraform_state_path
# Upload basepath # Upload basepath
def upload_path def upload_path
# TODO: Use configuration solver path = gitlab_config.dig(env, 'uploads', 'storage_path') ||
File.join(Gitlab.config.uploads.storage_path, 'uploads') gitlab_basepath.join(DEFAULT_UPLOADS_PATH)
absolute_path(path).join('uploads')
end end
def env def env
......
...@@ -53,7 +53,7 @@ test: ...@@ -53,7 +53,7 @@ test:
aws_secret_access_key: AWS_SECRET_ACCESS_KEY aws_secret_access_key: AWS_SECRET_ACCESS_KEY
region: us-east-1 region: us-east-1
uploads: uploads:
storage_path: tmp/tests/public storage_path: /tmp/gitlab/full/public
object_store: object_store:
enabled: false enabled: false
connection: connection:
......
...@@ -251,6 +251,32 @@ ...@@ -251,6 +251,32 @@
end end
end end
describe '#upload_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.upload_path).to eq(fake_gitlab_basepath.join('public/uploads'))
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.upload_path).to eq(fake_gitlab_basepath.join('tmp/tests/public/uploads'))
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.upload_path).to eq(Pathname('/tmp/gitlab/full/public/uploads'))
end
end
end
describe '#gitlab_shared_path' do describe '#gitlab_shared_path' do
context 'with shared path not configured in gitlab.yml' do context 'with shared path not configured in gitlab.yml' do
it 'raises an error' do it 'raises an error' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册