condition

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EQ        = "EQ"
	NE        = "NE"
	GT        = "GT"
	LT        = "LT"
	GE        = "GE"
	LE        = "LE"
	REGEXP    = "REGEXP"
	NOTREGEXP = "NOTREGEXP"
	IN        = "IN"
	NOTIN     = "NOTIN"
)

accepted condition operators

View Source
const (
	SKIP  = "skip"
	CHECK = "check"
)
View Source
const (
	// ForEachChildren executes the condition on the children of a foreach step.
	// The children are created, the condition is copied in them, then run.
	// This is the default value.
	ForEachChildren = "children"
	// ForEachParent executes the condition on the foreach step itself.
	ForEachParent = "parent"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Assert

type Assert struct {
	Value         string `json:"value"`
	Operator      string `json:"operator"`
	Expected      string `json:"expected"`
	ListSeparator string `json:"list_separator"`
	Message       string `json:"message"`
}

Assert describes a challenge to a value an expected value is compared through an operator the intent of this condition can be explained through a contextual message for clearer error surfacing

func (*Assert) Eval

func (a *Assert) Eval(v *values.Values, item interface{}, stepName string) error

Eval applies a condition on a particular item, asserting if the item meets the condition or not

func (*Assert) Valid

func (a *Assert) Valid() error

Valid asserts that a condition's definition is valid ie. the operator is among the accepted values listed above

type Condition

type Condition struct {
	Type    string            `json:"type"`
	If      []*Assert         `json:"if"`
	Then    map[string]string `json:"then"`
	Final   bool              `json:"final"`
	ForEach string            `json:"foreach"`
	Message string            `json:"message"`
}

Condition defines a condition to be evaluated before or after a step's action

func (*Condition) Eval

func (sc *Condition) Eval(v *values.Values, item interface{}, stepName string) error

Eval runs the condition against a set of values, evaluating the underlying Condition

func (*Condition) Valid added in v1.28.0

func (c *Condition) Valid() error

Valid asserts that a condition's definition is valid ie. the type and foreach are among the accepted values listed above

type ErrConditionNotMet

type ErrConditionNotMet string

ErrConditionNotMet is the typed error returned by Condition when its evaluation fails

func (ErrConditionNotMet) Error

func (e ErrConditionNotMet) Error() string

Error implements standard error

Jump to

Keyboard shortcuts

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