config

package
v1.5.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: GPL-2.0, GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config parses github-scout configuration from environment variables. The env var names (GITHUB_TOKEN, GITHUB_OWNER, SCAN_INTERVAL, LOOKBACK_HOURS, LOG_LEVEL, EXCLUDE_REPOS, CODE_SCANNING_EXCLUDE_REPOS, PR_EXCLUDE_QUERY, ISSUE_EXCLUDE_QUERY) are an inviolate compose-file contract — the in-memory shape may evolve, but the names and parsing semantics must stay stable.

SCAN_INTERVAL follows the shared scheduled-app convention (DUMP_INTERVAL, SCHEDULE_INTERVAL, SYNC_INTERVAL, …): a Go duration string, with the sentinels off / disabled / 0 / 0s selecting resident-idle mode (no internal timer; scans are driven externally by `github-scout trigger`, e.g. an Ofelia job-exec).

Index

Constants

View Source
const (
	// DefaultScanInterval is the gap between scans in scheduled mode. 15
	// minutes keeps the "what just broke" latency low while staying far
	// under GitHub's authenticated 5000 req/hour budget (a few hundred
	// calls per scan).
	DefaultScanInterval = 15 * time.Minute
	// DefaultLookbackHours bounds how far back a scan looks for failures.
	// 72h means a Friday-night failure is still surfaced on Monday. It
	// also bounds the in-memory dedup set and the per-repo API page count.
	DefaultLookbackHours = 72
	// DefaultPRExclude filters Renovate's PRs out of the open-PR signal.
	// Renovate PRs are high-volume bot noise, not "needs a human" work.
	DefaultPRExclude = "-author:app/renovate"
	// DefaultIssueExclude filters Renovate "Dependency Dashboard" issues
	// (authored by the repo owner but carrying the `renovate` label) and
	// auto-generated trackers (gremlins mutation-testing issues carry the
	// `auto-generated` label) out of the open-issue signal.
	DefaultIssueExclude = "-author:app/renovate -label:renovate -label:auto-generated"
)

Defaults for env-var-backed fields.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ExcludeRepos is a set of repo names (not full names) to skip across
	// all signals. Used to silence repos that legitimately fail or that the
	// owner does not want surfaced. Keyed by bare name for O(1) lookup.
	ExcludeRepos map[string]bool
	// CodeScanningExcludeRepos is a set of repo names (not full names) to skip
	// for the code-scanning signal ONLY, while still scanning them for runs,
	// PRs, and issues. Use it for repos whose code-scanning API always fails
	// expectedly — a private repo on a plan without GitHub Advanced Security
	// 403s every scan — so that expected failure stops marking every scan
	// degraded, without dropping the repo's other signals (which EXCLUDE_REPOS
	// would). Keyed by bare name for O(1) lookup.
	CodeScanningExcludeRepos map[string]bool
	// Token is the GitHub PAT used for API auth. Never logged.
	Token string
	// Owner is the GitHub login (user or org) whose repos are scanned.
	Owner string
	// PRExclude is appended to the open-PR search query to filter bot noise.
	PRExclude string
	// IssueExclude is appended to the open-issue search query to filter
	// bot / auto-generated noise.
	IssueExclude string
	// ScanInterval is the gap between scans in scheduled mode. Zero selects
	// resident-idle mode: no internal timer, scans driven externally by the
	// `trigger` subcommand (Ofelia job-exec). Parsed from SCAN_INTERVAL.
	ScanInterval time.Duration
	// Lookback is how far back each scan considers runs.
	Lookback time.Duration
	// LogLevel is parsed from LOG_LEVEL.
	LogLevel slog.Level
}

Config is the effective runtime configuration after env var parsing.

func Load

func Load() Config

Load reads configuration from the environment with sensible defaults.

func (*Config) Valid

func (c *Config) Valid() bool

Valid reports whether the config has the minimum needed to run: an owner to scan and a token to authenticate. Unauthenticated GitHub API access is rate-limited to 60 req/hour, far too low for a multi-repo scan, so a missing token is fatal misconfiguration rather than a degraded mode. Pointer receiver: Config is large enough that copying it per call is wasteful.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL