Class: VectorAmp::GitLabSource

Inherits:
Source
  • Object
show all
Defined in:
lib/vector_amp/source.rb

Overview

GitLab ingestion source for gitlab.com or a self-managed instance.

Authenticates with an access token (auth_mode: "token" plus access_token) or a stored OAuth connection (connection_id). At least one group or project is required.

Constant Summary

Constants inherited from Source

Source::SUPPORTED_SOURCE_TYPES

Instance Attribute Summary

Attributes inherited from Source

#config, #description, #id, #metadata, #name, #source_type

Instance Method Summary collapse

Methods inherited from Source

#[], from_api, #inspect, normalize_hash, #to_create_body, #to_h

Constructor Details

#initialize(groups: nil, projects: nil, name: nil, auth_mode: "oauth", gitlab_url: "https://gitlab.com", access_token: nil, connection_id: nil, ref_mode: nil, refs: nil, excluded_refs: nil, active_branch_days: nil, include_merge_requests: nil, include_review_threads: nil, include_direct_commits: nil, include_globs: nil, exclude_globs: nil, max_file_size_bytes: nil, description: nil, metadata: nil, id: nil, **config) ⇒ GitLabSource

Parameters:

  • groups (String, Array<String>, nil) (defaults to: nil)

    group paths; required unless projects is given.

  • projects (String, Array<String>, nil) (defaults to: nil)

    project paths with namespace; required unless groups is given.

  • name (String, nil) (defaults to: nil)

    defaults to gitlab-<path> from the first project or group.

  • auth_mode (String) (defaults to: "oauth")

    oauth (default) or token.

  • gitlab_url (String) (defaults to: "https://gitlab.com")

    instance base URL; defaults to https://gitlab.com.

  • access_token (String, nil) (defaults to: nil)

    personal or group access token for auth_mode: "token".

  • connection_id (String, nil) (defaults to: nil)

    optional stored OAuth connection id used instead of a token.

  • ref_mode (String, nil) (defaults to: nil)

    active (server default), default, or explicit.

  • refs (String, Array<String>, nil) (defaults to: nil)

    explicit branch names for ref_mode: "explicit".

  • excluded_refs (String, Array<String>, nil) (defaults to: nil)

    branch names to skip.

  • active_branch_days (Integer, nil) (defaults to: nil)

    activity window in days (1-90); server default 7.

  • include_merge_requests (Boolean, nil) (defaults to: nil)

    ingest merge requests; server default true.

  • include_review_threads (Boolean, nil) (defaults to: nil)

    ingest review discussions; server default true.

  • include_direct_commits (Boolean, nil) (defaults to: nil)

    ingest commits outside a merge request; server default true.

  • include_globs (String, Array<String>, nil) (defaults to: nil)

    path globs to include; server default **/*.

  • exclude_globs (String, Array<String>, nil) (defaults to: nil)

    path globs to skip.

  • max_file_size_bytes (Integer, nil) (defaults to: nil)

    per-file ceiling (1-25_000_000); server default 1_000_000.

  • description (String, nil) (defaults to: nil)

    optional description.

  • metadata (Hash, nil) (defaults to: nil)

    optional metadata.

  • id (String, nil) (defaults to: nil)

    optional API source id.

  • config (Hash)

    additional GitLab-source config forwarded to the API.



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/vector_amp/source.rb', line 473

def initialize(groups: nil, projects: nil, name: nil, auth_mode: "oauth", gitlab_url: "https://gitlab.com",
               access_token: nil, connection_id: nil, ref_mode: nil, refs: nil, excluded_refs: nil,
               active_branch_days: nil, include_merge_requests: nil, include_review_threads: nil,
               include_direct_commits: nil, include_globs: nil, exclude_globs: nil, max_file_size_bytes: nil,
               description: nil, metadata: nil, id: nil, **config)
  group_list = Array(groups)
  project_list = Array(projects)
  if group_list.empty? && project_list.empty?
    raise ArgumentError, "groups or projects is required"
  end

  super(
    id: id,
    source_type: "gitlab",
    name: name || SourceNames.gitlab(projects: project_list, groups: group_list),
    description: description,
    metadata: ,
    config: Utils.compact_hash(config.merge(
      auth_mode: auth_mode,
      gitlab_url: gitlab_url,
      groups: group_list.empty? ? nil : group_list,
      projects: project_list.empty? ? nil : project_list,
      access_token: access_token,
      connection_id: connection_id,
      ref_mode: ref_mode,
      refs: refs.nil? ? nil : Array(refs),
      excluded_refs: excluded_refs.nil? ? nil : Array(excluded_refs),
      active_branch_days: active_branch_days,
      include_merge_requests: include_merge_requests,
      include_review_threads: include_review_threads,
      include_direct_commits: include_direct_commits,
      include_globs: include_globs.nil? ? nil : Array(include_globs),
      exclude_globs: exclude_globs.nil? ? nil : Array(exclude_globs),
      max_file_size_bytes: max_file_size_bytes
    ))
  )
end