Documentation
¶
Overview ¶
Package capability is a room's inventory of what it can do: a declared list of named claims, a probe for each, and the newest result of every probe. It imports nothing from the daemon, the hub or the store.
A probe is an argv list and never a shell string. The only commands that run are the ones in the declared list, and an asker names ids from it. Output is cut and scrubbed before it is kept, and the raw output never leaves this package.
Index ¶
Constants ¶
const ( Pass = "pass" Fail = "fail" Unknown = "unknown" DefaultTimeout = 10 * time.Second MaxTimeout = 120 * time.Second ReasonMax = 200 )
Variables ¶
var ErrBusy = errors.New("a capability run is already going")
ErrBusy is a run asked for while one is going.
Functions ¶
Types ¶
type Auditor ¶
type Auditor struct {
// Scratch is a directory the room made for probes that write, and nothing else is written to.
Scratch string
// Repos is where ${ATRIUM_REPOS} points when the environment does not say.
Repos string
// File, when set, is where results are kept across a restart.
File string
Now func() time.Time
// contains filtered or unexported fields
}
Auditor runs the declared probes and keeps the newest result of each.
func NewAuditor ¶
NewAuditor starts with list and any results saved in file.
func (*Auditor) Due ¶
Due is the capabilities whose newest result is older than their own cadence (every, else sixHours).
func (*Auditor) Probe ¶
Probe runs one capability's probe and judges it. It never returns an error: a probe that cannot run is a result.
func (*Auditor) Run ¶
Run probes the named capabilities, or all of them when ids is empty, and anything they need first. Ids not in the declared list are refused before anything runs.
type Cap ¶
type Cap struct {
ID string `yaml:"id" json:"id"`
Kind string `yaml:"kind" json:"kind"`
Probe []string `yaml:"probe" json:"-"`
// Dir is where the probe runs. ${NAME} is read from the environment, and ${SCRATCH} is a directory the room made.
Dir string `yaml:"dir,omitempty" json:"-"`
Timeout string `yaml:"timeout,omitempty" json:"-"`
Pass string `yaml:"pass,omitempty" json:"-"`
Match string `yaml:"match,omitempty" json:"-"`
Version string `yaml:"version,omitempty" json:"-"`
Needs []string `yaml:"needs,omitempty" json:"needs,omitempty"`
// Optional shows a failure neutral everywhere. NotExpected does the same on the rooms it names.
Optional bool `yaml:"optional,omitempty" json:"optional,omitempty"`
NotExpected []string `yaml:"not_expected,omitempty" json:"not_expected,omitempty"`
Every string `yaml:"every,omitempty" json:"every,omitempty"`
Fix string `yaml:"fix,omitempty" json:"fix,omitempty"`
}
Cap is one declared capability.
type List ¶
type List struct {
Version int `yaml:"version" json:"version"`
Caps []Cap `yaml:"caps" json:"caps"`
}
List is the declared list.
func Load ¶
Load is the shipped list with the room's own additions from path laid over it. A local entry adds or replaces by id. A missing file is no additions, and a file that does not parse is an error so the room says so instead of dropping it.