Documentation
¶
Overview ¶
Package config loads and validates a baton file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid config")
ErrInvalid marks a configuration error.
Functions ¶
Types ¶
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 ¶
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 ¶
Filter returns the component's release filter. Call it only on a validated config, whose patterns are known to compile.
func (*Component) SourceKind ¶
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 ¶
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 ¶
TriggerFilter returns the filter for releases that trigger a rollout: the source component's filter, narrowed by the trigger.
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 ¶
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.