Documentation
¶
Overview ¶
Package conditions decides which catalog items may be installed on this machine. Each item's installable_condition is an expr expression (github.com/expr-lang/expr) evaluated against facts that pkg/facts gathers. See site/src/content/docs/guides/conditions.md. It has no platform code, so makecatalogs can check expressions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply evaluates every item's installable_condition against facts and sets NotInstallable on the items it rejects, so the lookups that choose an item to install skip them. Unknown rejects an item like false: the item is not installable here until the machine has the facts it names.
func Check ¶
Check reports a syntax error in condition without facts, for tools that build catalogs. A condition that passes can still fail on a machine, for example by naming a fact the machine does not have.
func Inputs ¶
Inputs returns, sorted, the facts condition reads, for a template render. A syntax error is an error, and so is a call to a time-dependent builtin such as now(), since the result would then depend on the clock rather than the facts. An empty condition reads nothing: Evaluate holds it True.
Types ¶
type Facts ¶
Facts maps a fact name to its value: a string, number, bool, or a list of them for the built-in facts; whatever JSON value a script printed for admin facts.
func SampleFacts ¶
SampleFacts returns an example value for every built-in fact SofCat collects on goos (darwin, windows or linux): the conditions guide's examples (site/src/content/docs/guides/conditions.md, "Built-in facts"). makecatalogs renders templates against them, since it has no machine. The per-OS tests in pkg/facts assert every built-in they collect is here, so the two cannot drift.
type Result ¶
type Result int
Result is a condition's outcome. Unknown means the condition names a fact this machine does not have, so it can be neither honoured nor refused.
func Evaluate ¶
Evaluate decides condition against facts. An empty condition is True. A condition that names an identifier absent from facts is Unknown, and missing lists those names. A syntax error, a runtime error, or a non-boolean result is False with the error, so a typo hides an item rather than installing it everywhere.