Class: Connectors::GitLab::Connector

Inherits:
Base::Connector show all
Defined in:
lib/connectors/gitlab/connector.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Connector

#do_health_check!, #is_healthy?

Constructor Details

#initialize(configuration: {}) ⇒ Connector

Returns a new instance of Connector.



39
40
41
42
43
44
45
46
# File 'lib/connectors/gitlab/connector.rb', line 39

def initialize(configuration: {})
  super

  @extractor = Connectors::GitLab::Extractor.new(
    :base_url => configuration.dig(:base_url, :value),
    :api_token => configuration.dig(:api_token, :value)
  )
end

Class Method Details

.configurable_fieldsObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/connectors/gitlab/connector.rb', line 27

def self.configurable_fields
  {
    :base_url => {
      :label => 'Base URL',
      :value => Connectors::GitLab::DEFAULT_BASE_URL
    },
    :api_key => {
       :label => 'API Key'
    }
  }
end

.display_nameObject



23
24
25
# File 'lib/connectors/gitlab/connector.rb', line 23

def self.display_name
  'GitLab Connector'
end

.service_typeObject



19
20
21
# File 'lib/connectors/gitlab/connector.rb', line 19

def self.service_type
  'gitlab'
end

Instance Method Details

#yield_documentsObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/connectors/gitlab/connector.rb', line 48

def yield_documents
  next_page_link = nil
  loop do
    next_page_link = @extractor.yield_projects_page(next_page_link) do |projects_chunk|
      projects_chunk.each do |project|
        yield Connectors::GitLab::Adapter.to_es_document(:project, project)
      end
    end
    break unless next_page_link.present?
  end
end