diff --git a/config/feature_flags/beta/single_relation_import.yml b/config/feature_flags/beta/single_relation_import.yml new file mode 100644 index 0000000000000000000000000000000000000000..312b3026d9a15f4b5bb1429553add6dc20d47e00 --- /dev/null +++ b/config/feature_flags/beta/single_relation_import.yml @@ -0,0 +1,9 @@ +--- +name: single_relation_import +feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/425798 +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/149444 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/455889 +milestone: '16.11' +group: group::import and integrate +type: beta +default_enabled: false diff --git a/doc/api/project_import_export.md b/doc/api/project_import_export.md index d667f95eb4483976a324e03d4e112ae6e565ffdb..ba0d435c8515418c4fda8be7a9a117d5e2b35b05 100644 --- a/doc/api/project_import_export.md +++ b/doc/api/project_import_export.md @@ -270,7 +270,7 @@ The `Content-Type` header must be `application/gzip`. ## Import a single relation -> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/425798) in GitLab 16.11. +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/425798) in GitLab 16.11 in [Beta](../policy/experiment-beta-support.md#beta)), [with a flag](../administration/feature_flags.md) named `single_relation_import`. Disabled by default. This endpoint accepts a project export archive and a named relation (issues, merge requests, pipelines, or milestones) and re-imports that relation, skipping @@ -318,7 +318,7 @@ curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/425798) in GitLab 16.11. -This endpoint fetches the status of any relation imports associated with a project. Because +This endpoint fetches the status of any relation imports associated with a project. Because only one relation import can be scheduled at a time, you can use this endpoint to check whether the previous import completed successfully. diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb index 8b23bcc52a5b3ff17f3de3fe76664c4901e82944..83b4e15ac27986b19c635019dd9f119df7d57ffb 100644 --- a/lib/api/project_import.rb +++ b/lib/api/project_import.rb @@ -239,6 +239,7 @@ def filtered_override_params(params) consumes ['multipart/form-data'] end post 'import-relation' do + not_found! unless Feature.enabled?(:single_relation_import, current_user, type: :beta) forbidden! unless Gitlab::CurrentSettings.import_sources.include?('gitlab_project') require_gitlab_workhorse! diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 1e28a6fdb6ec76ad0a6befb5f5e7161ff812d6e8..9bc4be936955f41639289b59a91d291852f57705 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -608,6 +608,20 @@ def stub_import(namespace) end end + context 'when the feature flag :single_relation_import is disabled' do + before do + stub_feature_flags(single_relation_import: false) + end + + it 'returns not found' do + params[:path] = 'any/project' + + perform_relation_import + + expect(response).to have_gitlab_http_status(:not_found) + end + end + def upload_relation_archive(file, headers = {}, params = {}) workhorse_finalize( api("/projects/import-relation", user),