summaryrefslogtreecommitdiff
path: root/lib/api/project_import.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-29 13:57:21 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-04-04 19:49:48 +0200
commite40c0085ef300aca38076af3ea2f227761084038 (patch)
tree46f24452583fe738e4e1117d8a7d149de078397d /lib/api/project_import.rb
parent11a9fbe65b22c334bc47edf0a23b89619766553d (diff)
downloadgitlab-ce-e40c0085ef300aca38076af3ea2f227761084038.tar.gz
Store override params as import data on projects
This means import data doesn't necessarily have to have an import_url anymore. The `ProjectImportData` could just contain the override data in it's serialized data attribute. The import data is automatically cleaned up after it is finished by the state machine.
Diffstat (limited to 'lib/api/project_import.rb')
-rw-r--r--lib/api/project_import.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb
index a509c1f32c1..303b58a5942 100644
--- a/lib/api/project_import.rb
+++ b/lib/api/project_import.rb
@@ -1,6 +1,7 @@
module API
class ProjectImport < Grape::API
include PaginationParams
+ include Helpers::ProjectsHelpers
helpers do
def import_params
@@ -25,6 +26,11 @@ module API
requires :path, type: String, desc: 'The new project path and name'
requires :file, type: File, desc: 'The project export file to be imported'
optional :namespace, type: String, desc: "The ID or name of the namespace that the project will be imported into. Defaults to the current user's namespace."
+ optional :override_params,
+ type: Hash,
+ desc: 'New project params to override values in the export' do
+ use :optional_project_params
+ end
end
desc 'Create a new project import' do
detail 'This feature was introduced in GitLab 10.6.'
@@ -47,7 +53,11 @@ module API
file: import_params[:file]['tempfile']
}
- project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute
+ override_params = import_params.delete(:override_params)
+
+ project = ::Projects::GitlabProjectsImportService.new(
+ current_user, project_params, override_params
+ ).execute
render_api_error!(project.errors.full_messages&.first, 400) unless project.saved?