summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/reader.rb
blob: 9e81c6a3d073653d5797ffd2c9b6f53b608de0fd (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
# frozen_string_literal: true

module Gitlab
  module ImportExport
    class Reader
      attr_reader :tree, :attributes_finder

      def initialize(shared:)
        @shared = shared

        @attributes_finder = Gitlab::ImportExport::AttributesFinder.new(
          config: ImportExport::Config.new.to_h)
      end

      # Outputs a hash in the format described here: http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html
      # for outputting a project in JSON format, including its relations and sub relations.
      def project_tree
        attributes_finder.find_root(:project)
      rescue => e
        @shared.error(e)
        false
      end

      def group_members_tree
        attributes_finder.find_root(:group_members)
      end
    end
  end
end