config

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config parses and validates xray TOML configuration with line-numbered diagnostics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BugsnagConn

type BugsnagConn struct {
	Token         string
	Projects      map[string]string // bugsnag project slug -> repo slug
	MaxWindowDays int               // 0 → connector default (60d)
}

type CircleCIConn

type CircleCIConn struct {
	Token    string
	Projects map[string]string // circleci project slug -> repo slug
}

type Config

type Config struct {
	Window                Window
	Teams                 map[string][]string
	CaptureHarnessContent bool
	Connectors            Connectors
}

Config is the parsed TOML configuration.

func Load

func Load(path string) (*Config, *toml.MetaData, error)

Load reads a TOML config file from path and returns the populated Config plus the toml.MetaData that produced it. The MetaData is needed by Validate for line-numbered diagnostics.

A malformed window string is reported as an error here rather than as a validation diagnostic: a window we cannot parse cannot be validated.

func (*Config) AllRepos

func (c *Config) AllRepos() []string

AllRepos flattens Teams into a deduplicated slice of repo slugs.

func (*Config) GitHubToken added in v0.4.3

func (c *Config) GitHubToken() string

GitHubToken returns the configured GitHub token, or "" when no GitHub connector is configured. Used by gitcli to authenticate clone and ls-remote against github.com without requiring ambient git auth.

func (*Config) RepoToTeam

func (c *Config) RepoToTeam(slug string) string

RepoToTeam returns the team a given repo slug belongs to. Empty string if the repo is not present in any team.

type Connectors

type Connectors struct {
	GitHub        *GitHubConn
	GitHubActions *GitHubActionsConn
	CircleCI      *CircleCIConn
	Sentry        *SentryConn
	Bugsnag       *BugsnagConn
	Honeycomb     *HoneycombConn
}

Connectors holds the optional per-source config. A nil pointer means the connector is not configured and is skipped at extract time.

type Diagnostic

type Diagnostic struct {
	File string
	Line int
	Path string
	Msg  string
}

Diagnostic is a single validation problem with a source location.

func Validate

func Validate(cfg *Config, meta *toml.MetaData, file string) []Diagnostic

Validate enforces the schema rules from docs/spec.md and returns one diagnostic per problem found. file is the source path used in diagnostic output.

Diagnostics are returned in source-line order so that the cli output is stable. An empty slice means the config is valid.

func (Diagnostic) Error

func (d Diagnostic) Error() string

Error renders the diagnostic in the spec format:

<file>:<line>: <path>: <msg>

type DurationSpec added in v0.4.9

type DurationSpec struct {
	Years  int
	Months int
	Days   int
	Raw    string // verbatim from TOML, e.g. "12m"
}

DurationSpec is a parsed duration string of the form Nu where u ∈ {y,m,w,d}. Calendar-accurate arithmetic is applied via time.AddDate, so "12m" is exactly 12 calendar months rather than 365 days.

type GitHubActionsConn

type GitHubActionsConn struct {
	Token string // optional; falls back to GitHub.Token
}

type GitHubConn

type GitHubConn struct {
	Token           string
	PRWindow        *Window            // nil → use global window for PR cluster extraction
	PRInflection    *time.Time         // operator-supplied inflection date (UTC midnight); nil = no sparse mode
	PRBracketWindow *DurationSpec      // ±N months/weeks/days full fidelity; nil = no sparse mode
	PRHistorySample *HistorySampleSpec // nil = skip pre-bracket extraction
}

type HistorySampleSpec added in v0.4.9

type HistorySampleSpec struct {
	Strategy string // always "monthly"
	N        int    // PRs per bucket (1–100)
	Random   bool   // true when ":random" suffix present
	Raw      string // verbatim from TOML
}

HistorySampleSpec is a parsed pr_history_sample string "monthly:N" or "monthly:N:random".

type HoneycombConn

type HoneycombConn struct {
	Token   string
	Dataset string
}

type SentryConn

type SentryConn struct {
	Token        string
	Organization string
	Projects     map[string]string // sentry project slug -> repo slug
}

type Window

type Window struct {
	Start time.Time
	End   time.Time
	Raw   string
}

Window is the inclusive UTC extraction window.

Jump to

Keyboard shortcuts

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