conditional

package
v0.0.0-...-02c76fb Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetaSwitchName is the metadata key for accessing the name of the switch
	// that contains this branch.
	MetaSwitchName = "conditional-switch-name"

	// MetaBranchName defines the name for the branch
	MetaBranchName = "conditional-name"

	// MetaUnrenderedPredicate contains the predicate string before being rendered
	MetaUnrenderedPredicate = "conditional-predicate-raw"

	// MetaRenderedPredicate contains the predicate string after rendering
	MetaRenderedPredicate = "conditional-predicate-rendered"

	// MetaConditionalName contains the name of the branch containing the node
	MetaConditionalName = "conditional-name"

	// MetaPeers contains the the current branch and all it's peers in order
	MetaPeers = "conditional-peers"

	// MetaPredicate contains the cached result of rendered predicate evaluation
	MetaPredicate = "conditional-predicate-results"

	// MetaType contains the type of the underlying node
	MetaType = "conditional-resource-type"
)
View Source
const (
	// NodeCatResource represents a NodeCat that is a node inside of a branch
	NodeCatResource = "resource"
	// NodeCatBranch represents a NodeCat that is a branch (case statement)
	NodeCatBranch = "branch"
	// NodeCatSwitch represents a conditional container type (switch statement)
	NodeCatSwitch = "switch"
)

Variables

View Source
var (
	// ErrUnrendered is returned when attempting to evaluate truthiness of an
	// unrendered predicate.
	ErrUnrendered = errors.New("cannot evaluate an unrendered predicate")
)

Functions

func IsConditional

func IsConditional(meta *node.Node) bool

IsConditional returns true if the graph is conditional

func IsTrue

func IsTrue(meta *node.Node) (bool, error)

IsTrue returns true if the predicate is true, and false otherwise.

func PeerBranches

func PeerBranches(g *graph.Graph, meta *node.Node) (out []*node.Node)

PeerBranches returns the branches nodes that are peers to the current node.

func PeerNodes

func PeerNodes(g *graph.Graph, meta *node.Node) (out []*node.Node)

PeerNodes returns a list of graph nodes that are part of the same switch statement and branch as the current node.

func RenderPredicate

func RenderPredicate(meta *node.Node, renderFunc func(string, string) (string, error)) (string, error)

RenderPredicate will attempt to render the predicate if it's not rendered, and return it. It takes a renderFunc in order to prevent circular imports when being used by render.

func ShouldEvaluate

func ShouldEvaluate(g *graph.Graph, meta *node.Node) (bool, error)

ShouldEvaluate returns true if the node is the first of it's peers that is true.

Types

type NodeCategory

type NodeCategory string

A NodeCategory represents the type of a node

Jump to

Keyboard shortcuts

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