Skip to content
代码片段 群组 项目
未验证 提交 a9a7d2ca 编辑于 作者: Aboobacker MK's avatar Aboobacker MK 提交者: GitLab
浏览文件

Merge branch '439811-avoid-copy-operation-when-uploading-terraform-modules' into 'master'

Avoid copy operation during Terraform modules registry uploads

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/150713



Merged-by: default avatarAboobacker MK <akarakath@gitlab.com>
Approved-by: default avatarJon Jenkins <jjenkins@gitlab.com>
Approved-by: default avatarAboobacker MK <akarakath@gitlab.com>
Co-authored-by: default avatarmoaz-khalifa <mkhalifa@gitlab.com>
No related branches found
No related tags found
无相关合并请求
---
name: skip_copy_operation_in_terraform_module_upload
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/439811
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/150713
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/457927
milestone: '17.0'
group: group::package registry
type: gitlab_com_derisk
default_enabled: false
......@@ -51,6 +51,19 @@ def finder_params
def package_name
"#{params[:module_name]}/#{params[:module_system]}"
end
def authorize_workhorse_params
params = {
subject: authorized_user_project,
maximum_size: authorized_user_project.actual_limits.terraform_module_max_file_size
}
if ::Feature.enabled?(:skip_copy_operation_in_terraform_module_upload, authorized_user_project)
params[:use_final_store_path] = true
end
params
end
end
params do
......@@ -127,10 +140,7 @@ def package_name
end
put :authorize do
authorize_workhorse!(
subject: authorized_user_project,
maximum_size: authorized_user_project.actual_limits.terraform_module_max_file_size
)
authorize_workhorse!(**authorize_workhorse_params)
end
desc 'Upload Terraform Module package file' do
......
......@@ -24,7 +24,7 @@
let(:url) { api("/projects/#{project.id}/packages/terraform/modules/mymodule/mysystem/1.0.0/file/authorize") }
let(:headers) { {} }
subject { put(url, headers: headers) }
subject(:api_request) { put(url, headers: headers) }
context 'with valid project' do
where(:visibility, :user_role, :member, :token_header, :token_type, :shared_examples_name, :expected_status) do
......@@ -79,6 +79,36 @@
it_behaves_like params[:shared_examples_name], params[:user_role], params[:expected_status], params[:member]
end
end
context 'for use_final_store_path' do
let(:headers) { workhorse_headers.merge('PRIVATE-TOKEN' => personal_access_token.token) }
before do
project.add_developer(user)
end
it 'sends use_final_store_path with true' do
expect(::Packages::PackageFileUploader).to receive(:workhorse_authorize).with(
hash_including(use_final_store_path: true, final_store_path_root_id: project.id)
).and_call_original
api_request
end
context 'when feature flag is disabled' do
before do
stub_feature_flags(skip_copy_operation_in_terraform_module_upload: false)
end
it 'sends use_final_store_path with false' do
expect(::Packages::PackageFileUploader).to receive(:workhorse_authorize).with(
hash_including(use_final_store_path: false)
).and_call_original
api_request
end
end
end
end
describe 'PUT /api/v4/projects/:project_id/packages/terraform/modules/:module_name/:module_system/:module_version/file' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册