config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config loads and validates a baton file.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("invalid config")

ErrInvalid marks a configuration error.

Functions

func ParseDate

func ParseDate(s string) (time.Time, error)

ParseDate parses a YYYY-MM-DD date as UTC midnight.

func ParseGrace

func ParseGrace(s string) (time.Duration, error)

ParseGrace parses a grace period such as "7d".

Types

type Check

type Check map[string]map[string]any

Check is one probe: a mapping with exactly one key, the probe kind.

func (Check) Probe

func (c Check) Probe() (kind string, spec map[string]any)

Probe returns the check's probe kind and spec.

type Checks

type Checks []Check

Checks are an obligation's probes, all of which must pass. The file takes one check as a mapping or several as a list.

func (*Checks) UnmarshalJSON

func (c *Checks) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a single check or a list of checks.

type Component

type Component struct {
	Repo     string    `json:"repo"`
	Source   string    `json:"source,omitempty"`   // "releases" (default) or "tags"
	Releases *Releases `json:"releases,omitempty"` // what counts as a release
	Since    string    `json:"since,omitempty"`    // YYYY-MM-DD the component started
	Owners   []string  `json:"owners,omitempty"`   // optional GitHub users or teams
}

Component is one repository in the project.

func (*Component) Filter

func (c *Component) Filter() source.Filter

Filter returns the component's release filter. Call it only on a validated config, whose patterns are known to compile.

func (*Component) SourceKind

func (c *Component) SourceKind() string

SourceKind reports where the component's versions come from.

type Config

type Config struct {
	Home       *Home                `json:"home,omitempty"`
	Inventory  *Inventory           `json:"inventory,omitempty"`
	Components map[string]Component `json:"components"`
	Rollouts   []Rollout            `json:"rollouts,omitempty"`
	Invariants []Obligation         `json:"invariants,omitempty"`
	Waivers    []Waiver             `json:"waivers,omitempty"`

	// Digest is the first 12 hex digits of the file's SHA-256, set by
	// Load, so issues can show which rules produced them.
	Digest string `json:"-"`
}

Config is a baton file.

func Load

func Load(path string, isProbe func(string) bool) (*Config, error)

Load reads and validates a baton file. isProbe reports whether a verify kind exists. Unknown keys are errors, so a misspelled key can't silently disable a rule.

func (*Config) TriggerFilter

func (c *Config) TriggerFilter(t Trigger) source.Filter

TriggerFilter returns the filter for releases that trigger a rollout: the source component's filter, narrowed by the trigger.

func (*Config) Validate

func (c *Config) Validate(isProbe func(string) bool) error

Validate checks references and cycles so a typo fails loudly instead of silently skipping an obligation.

type Home

type Home struct {
	Repo string `json:"repo"`
}

Home is the project's baton repo, which holds the parent rollout issues. Without it, parents go to the triggering repo.

type Inventory

type Inventory struct {
	Component string `json:"component"`
	Path      string `json:"path"`
}

Inventory points at the Security Insights file that lists the project's repositories. Every component must appear in it.

type Obligation

type Obligation struct {
	ID     string   `json:"id"`
	Type   string   `json:"type,omitempty"` // catalog type, for reporting
	Target string   `json:"target"`
	Needs  []string `json:"needs,omitempty"`
	Action string   `json:"action"`
	Verify Checks   `json:"verify"`
	Grace  string   `json:"grace,omitempty"`
}

Obligation is an action owed by Target, verified by one probe.

type Releases

type Releases struct {
	Tag        string `json:"tag,omitempty"`        // RE2 pattern the tag must match
	Prerelease bool   `json:"prerelease,omitempty"` // count prereleases
	Order      string `json:"order,omitempty"`      // version (default), published, or forge
}

Releases says which of a component's tags count as releases.

type Rollout

type Rollout struct {
	ID          string       `json:"id"`
	When        Trigger      `json:"when"`
	Obligations []Obligation `json:"obligations"`
}

Rollout is one trigger and the obligations it creates.

type Trigger

type Trigger struct {
	Release string `json:"release"`
	Level   string `json:"level,omitempty"` // major, minor, or patch (default)
	Tag     string `json:"tag,omitempty"`   // RE2 pattern, on top of the component's
}

Trigger is {release: <component>}. More event kinds come later.

type Waiver

type Waiver struct {
	Obligation string `json:"obligation"`        // "<rollout>/<id>" or invariant id
	Binding    string `json:"binding,omitempty"` // e.g. "scorecard@v5.6.0"
	Approver   string `json:"approver"`
	Reason     string `json:"reason"`
	Expires    string `json:"expires"` // YYYY-MM-DD
}

Waiver excuses one obligation, optionally for one binding, until it expires. It lives in the file so it goes through review.

Jump to

Keyboard shortcuts

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