control

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: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadPredicate

func BadPredicate(p string) error

BadPredicate returns a new error for an invalid predicate

func InnerText

func InnerText(n *parse.Node, data []byte) ([]byte, error)

InnerText returns the text inside of a *parse.Node whose ObjectItem has a value of type *ast.ObjectType.

func IsSwitchNode

func IsSwitchNode(n *parse.Node) bool

IsSwitchNode returns true if the parse node represents a switch statement

func NewTypeError

func NewTypeError(expected string, actual interface{}) error

NewTypeError returns a new TypeError with the appropriate expected and actual types.

Types

type Case

type Case struct {
	Name       string
	Predicate  string
	InnerNodes []*parse.Node
}

Case represents a case structure from a switch element. Each case may have multiple nodes that will be expanded from the predicate.

func Cases

func Cases(s *Switch, data []byte) ([]*Case, error)

Cases returns a slice of cases

func ParseCase

func ParseCase(n *parse.Node, data []byte) (*Case, error)

ParseCase will parse a `case` or `default` node

func ParseSwitchConditional

func ParseSwitchConditional(n *parse.Node, data []byte) (*Case, error)

ParseSwitchConditional generates a case statement from an ast node at the switch statement level. The node should be an *ast.ObjectItem whose Val is an *ast.ObjectType

func (*Case) GenerateNode

func (c *Case) GenerateNode() (*parse.Node, error)

GenerateNode generates a parse.Node for the macro-expanded placeholder from the case clause

type CasePreparer

type CasePreparer struct {
	Name string `hcl:"name"`
}

CasePreparer contains generated case macro information

func (*CasePreparer) Prepare

Prepare does stuff

type CaseTask

type CaseTask struct {
	Name string
	// contains filtered or unexported fields
}

CaseTask represents a task and is used to determine whether a conditional task should evaluate or not

func (*CaseTask) Apply

Apply does stuff

func (*CaseTask) Check

Check does stuff

func (*CaseTask) GetParent

func (c *CaseTask) GetParent() *SwitchTask

GetParent gets the parent of a case

func (*CaseTask) IsDefault

func (c *CaseTask) IsDefault() bool

IsDefault returns true if the case is a default statement

func (*CaseTask) SetParent

func (c *CaseTask) SetParent(s *SwitchTask)

SetParent set's the parent of a case statement

func (*CaseTask) String

func (c *CaseTask) String() string

type NopTask

type NopTask struct {
	resource.Status
	Predicate string
}

NopTask does nothing, verbosely

func (*NopTask) Apply

Apply does nothing, verbosely

func (*NopTask) Check

Check does nothing, verbosely

type Switch

type Switch struct {
	Name     string
	Branches []*Case
	Node     *parse.Node
}

Switch represents a switch element

func NewSwitch

func NewSwitch(n *parse.Node, data []byte) (*Switch, error)

NewSwitch constructs a *Switch from a switch node

func (*Switch) BranchNames

func (s *Switch) BranchNames() (out []string)

BranchNames returns the branches in user-specified order

func (*Switch) GenerateNode

func (s *Switch) GenerateNode() (*parse.Node, error)

GenerateNode generates a parse.Node for the macro-expanded placeholder from the switch statement

type SwitchPreparer

type SwitchPreparer struct {
	Branches []string `hcl:"branches"`
}

SwitchPreparer represents a switch resource; the task it generates simply wraps the values and will not do anything during check or apply.

func (*SwitchPreparer) Prepare

Prepare does stuff

type SwitchTask

type SwitchTask struct {
	Branches []string
	// contains filtered or unexported fields
}

SwitchTask represents a resource.Task for a switch node. It does not perform any operations and exists to provide structure to conditional evaluation in the graph and holds predicate state information.

func (*SwitchTask) AppendCase

func (s *SwitchTask) AppendCase(c *CaseTask)

AppendCase adds a case statement to the list of cases

func (*SwitchTask) Apply

Apply does stuff

func (*SwitchTask) Cases

func (s *SwitchTask) Cases() []*CaseTask

Cases returns the embedded cases

func (*SwitchTask) Check

Check does stuff

func (*SwitchTask) SortCases

func (s *SwitchTask) SortCases()

SortCases ensures that the ordering of the cases slice mirrors the ordering of the Branches slice. Because branches is the canonical order of evaluation based on the HCL file and cases may be appended to the list in an unknown order due to non-deterministic map evaluation we need to re-sort the list.

func (*SwitchTask) String

func (s *SwitchTask) String() string

String displays a switch statement; useful for debugging and errors

Jump to

Keyboard shortcuts

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