Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeHook() mapstructure.DecodeHookFunc
- func RegisterPredicate(name string, fn PredicateFunc)
- func ValidateStep(condition Condition) error
- type Condition
- func (c Condition) Evaluate(ctx Context) bool
- func (c Condition) EvaluateE(ctx Context) (bool, error)
- func (c Condition) EvaluateWithImplicitSuccess(ctx Context) bool
- func (c Condition) EvaluateWithImplicitSuccessE(ctx Context) (bool, error)
- func (c Condition) IsZero() bool
- func (c Condition) MarshalJSON() ([]byte, error)
- func (c Condition) MentionsAny(names ...string) bool
- func (c Condition) MentionsLifecycleStatus() bool
- func (c *Condition) UnmarshalJSON(data []byte) error
- func (c *Condition) UnmarshalYAML(unmarshal func(any) error) error
- type Context
- type Node
- type PredicateFunc
Constants ¶
const ( // PredicateCI matches when Atmos is running in a detected CI environment. PredicateCI = "ci" // PredicateLocal matches when Atmos is not running in a detected CI environment. PredicateLocal = "local" // PredicateAlways always matches. PredicateAlways = "always" // PredicateNever never matches. PredicateNever = "never" // PredicateSuccess matches a successful lifecycle status. PredicateSuccess = "success" // PredicateFailure matches a failed lifecycle status. PredicateFailure = "failure" CELTag = "!cel" )
Variables ¶
var ErrInvalidWhenCondition = errors.New("invalid when condition")
ErrInvalidWhenCondition is returned when a `when` value cannot be normalized or evaluated.
Functions ¶
func DecodeHook ¶
func DecodeHook() mapstructure.DecodeHookFunc
DecodeHook lets Viper/mapstructure decode string/list/map values into Condition fields.
func RegisterPredicate ¶
func RegisterPredicate(name string, fn PredicateFunc)
RegisterPredicate adds or replaces a named condition predicate.
func ValidateStep ¶
ValidateStep validates predicates used by workflow and custom command steps. Step runners evaluate lifecycle predicates against the current run status so cleanup steps can use `failure` and `always`.
Types ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition is the normalized representation of a step/hook `when` value.
func (Condition) Evaluate ¶
Evaluate returns whether the condition matches the supplied context. Empty conditions match by default. Evaluation errors return false; callers that need diagnostics should use EvaluateE.
func (Condition) EvaluateE ¶
EvaluateE returns whether the condition matches the supplied context and reports CEL runtime errors.
func (Condition) EvaluateWithImplicitSuccess ¶
EvaluateWithImplicitSuccess applies the hook-specific default: a condition that does not mention lifecycle status also requires success.
func (Condition) EvaluateWithImplicitSuccessE ¶
EvaluateWithImplicitSuccessE is EvaluateWithImplicitSuccess with error reporting.
func (Condition) MarshalJSON ¶
MarshalJSON preserves conditions when command configs are cloned through JSON.
func (Condition) MentionsAny ¶
MentionsAny reports whether any predicate with one of the supplied names is present in the condition tree.
func (Condition) MentionsLifecycleStatus ¶
MentionsLifecycleStatus reports whether the condition explicitly reasons about lifecycle status, either through a status predicate or a CEL `status` reference.
func (*Condition) UnmarshalJSON ¶
UnmarshalJSON supports JSON config files and internal command cloning.
type Context ¶
type Context struct {
CI bool
Status string
Stack string
Component string
Workflow string
Step string
Hook string
Event string
Env map[string]string
}
Context carries runtime facts used to evaluate a declarative `when`.
type Node ¶
type Node struct {
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Expr string `json:"expr,omitempty"`
Children []Node `json:"children,omitempty"`
// contains filtered or unexported fields
}
Node is a small AST for declarative conditions.
type PredicateFunc ¶
PredicateFunc evaluates a named condition predicate against runtime facts.