diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/controllers/import/bulk_imports_controller.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/controllers/import/bulk_imports_controller.rb')
-rw-r--r-- | app/controllers/import/bulk_imports_controller.rb | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/app/controllers/import/bulk_imports_controller.rb b/app/controllers/import/bulk_imports_controller.rb index cb2922c2d47..78f4a0cffca 100644 --- a/app/controllers/import/bulk_imports_controller.rb +++ b/app/controllers/import/bulk_imports_controller.rb @@ -6,13 +6,13 @@ class Import::BulkImportsController < ApplicationController feature_category :importers - rescue_from Gitlab::BulkImport::Client::ConnectionError, with: :bulk_import_connection_error + rescue_from BulkImports::Clients::Http::ConnectionError, with: :bulk_import_connection_error def configure - session[access_token_key] = params[access_token_key]&.strip - session[url_key] = params[url_key] + session[access_token_key] = configure_params[access_token_key]&.strip + session[url_key] = configure_params[url_key] - redirect_to status_import_bulk_import_url + redirect_to status_import_bulk_imports_url end def status @@ -25,6 +25,12 @@ class Import::BulkImportsController < ApplicationController end end + def create + BulkImportService.new(current_user, create_params, credentials).execute + + render json: :ok + end + private def serialized_importable_data @@ -36,20 +42,33 @@ class Import::BulkImportsController < ApplicationController end def importable_data - client.get('groups', top_level_only: true) + client.get('groups', top_level_only: true).parsed_response end def client - @client ||= Gitlab::BulkImport::Client.new( + @client ||= BulkImports::Clients::Http.new( uri: session[url_key], token: session[access_token_key] ) end - def import_params + def configure_params params.permit(access_token_key, url_key) end + def create_params + params.permit(:bulk_import, [*bulk_import_params]) + end + + def bulk_import_params + %i[ + source_type + source_full_path + destination_name + destination_namespace + ] + end + def ensure_group_import_enabled render_404 unless Feature.enabled?(:bulk_import) end @@ -106,4 +125,11 @@ class Import::BulkImportsController < ApplicationController session[url_key] = nil session[access_token_key] = nil end + + def credentials + { + url: session[url_key], + access_token: [access_token_key] + } + end end |