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

project_attributes_transformer.rb « transformers « projects « bulk_imports « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 205c3185f722f97dcfb12d208b0d47fdd7b45e88 (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
# frozen_string_literal: true

module BulkImports
  module Projects
    module Transformers
      class ProjectAttributesTransformer
        PROJECT_IMPORT_TYPE = 'gitlab_project_migration'

        def transform(context, data)
          project = {}
          entity = context.entity
          visibility = data.delete('visibility')

          project[:name] = entity.destination_slug
          project[:path] = entity.destination_slug.parameterize
          project[:created_at] = data['created_at']
          project[:import_type] = PROJECT_IMPORT_TYPE
          project[:visibility_level] = Gitlab::VisibilityLevel.string_options[visibility] if visibility.present?
          project[:namespace_id] = Namespace.find_by_full_path(entity.destination_namespace)&.id if entity.destination_namespace.present?

          project
        end
      end
    end
  end
end