Class: VectorAmp::GitHubSource

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

Overview

GitHub ingestion source backed by the VectorAmp GitHub App.

Repositories, active branches, pull requests, and review discussions are read through a GitHub App installation, so no token is passed to the SDK. Install the VectorAmp GitHub App from the Sources page in the app first; the installation id shown there is what this class needs.

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(installation_id:, repositories:, name: nil, ref_mode: nil, refs: nil, excluded_refs: nil, active_branch_days: nil, include_pull_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) ⇒ GitHubSource

Parameters:

  • installation_id (Integer)

    required GitHub App installation id; must be positive.

  • repositories (String, Array<String>)

    required owner/repo full names.

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

    defaults to github-<owner>-<repo> from the first repository.

  • 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_pull_requests (Boolean, nil) (defaults to: nil)

    ingest pull 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 pull 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 GitHub-source config forwarded to the API.

Raises:

  • (ArgumentError)


410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/vector_amp/source.rb', line 410

def initialize(installation_id:, repositories:, name: nil, ref_mode: nil, refs: nil, excluded_refs: nil,
               active_branch_days: nil, include_pull_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)
  unless installation_id.is_a?(Integer) && installation_id.positive?
    raise ArgumentError, "installation_id must be a positive Integer"
  end

  repository_list = Array(repositories)
  raise ArgumentError, "repositories must not be empty" if repository_list.empty?

  super(
    id: id,
    source_type: "github",
    name: name || SourceNames.github(repositories: repository_list),
    description: description,
    metadata: ,
    config: Utils.compact_hash(config.merge(
      installation_id: installation_id,
      repositories: repository_list,
      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_pull_requests: include_pull_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