Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_pipeline.rb « pipelines « projects « bulk_imports « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 22384a96aa5c8517491661ee7409aba1afe99cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module BulkImports
  module Projects
    module Pipelines
      class ProjectPipeline
        include Pipeline
        include HexdigestCacheStrategy

        abort_on_failure!

        extractor ::BulkImports::Common::Extractors::GraphqlExtractor, query: Graphql::GetProjectQuery
        transformer ::BulkImports::Common::Transformers::ProhibitedAttributesTransformer
        transformer ::BulkImports::Projects::Transformers::ProjectAttributesTransformer

        def load(context, data)
          project = ::Projects::CreateService.new(context.current_user, data).execute

          if project.persisted?
            context.entity.update!(project: project)

            project
          else
            raise(::BulkImports::Error, "Unable to import project #{project.full_path}. #{project.errors.full_messages}.")
          end
        end
      end
    end
  end
end