Documentation ¶
Index ¶
- func BadPredicate(p string) error
- func InnerText(n *parse.Node, data []byte) ([]byte, error)
- func IsSwitchNode(n *parse.Node) bool
- func NewTypeError(expected string, actual interface{}) error
- type Case
- type CasePreparer
- type CaseTask
- func (c *CaseTask) Apply(context.Context) (resource.TaskStatus, error)
- func (c *CaseTask) Check(context.Context, resource.Renderer) (resource.TaskStatus, error)
- func (c *CaseTask) GetParent() *SwitchTask
- func (c *CaseTask) IsDefault() bool
- func (c *CaseTask) SetParent(s *SwitchTask)
- func (c *CaseTask) String() string
- type NopTask
- type Switch
- type SwitchPreparer
- type SwitchTask
- func (s *SwitchTask) AppendCase(c *CaseTask)
- func (s *SwitchTask) Apply(context.Context) (resource.TaskStatus, error)
- func (s *SwitchTask) Cases() []*CaseTask
- func (s *SwitchTask) Check(context.Context, resource.Renderer) (resource.TaskStatus, error)
- func (s *SwitchTask) SortCases()
- func (s *SwitchTask) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadPredicate ¶
BadPredicate returns a new error for an invalid predicate
func InnerText ¶
InnerText returns the text inside of a *parse.Node whose ObjectItem has a value of type *ast.ObjectType.
func IsSwitchNode ¶
IsSwitchNode returns true if the parse node represents a switch statement
func NewTypeError ¶
NewTypeError returns a new TypeError with the appropriate expected and actual types.
Types ¶
type Case ¶
Case represents a case structure from a switch element. Each case may have multiple nodes that will be expanded from the predicate.
func ParseSwitchConditional ¶
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
type CasePreparer ¶
type CasePreparer struct {
Name string `hcl:"name"`
}
CasePreparer contains generated case macro information
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) GetParent ¶
func (c *CaseTask) GetParent() *SwitchTask
GetParent gets the parent of a case
func (*CaseTask) SetParent ¶
func (c *CaseTask) SetParent(s *SwitchTask)
SetParent set's the parent of a case statement
type NopTask ¶
NopTask does nothing, verbosely
type Switch ¶
Switch represents a switch element
func (*Switch) BranchNames ¶
BranchNames returns the branches in user-specified order
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.
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 ¶
func (s *SwitchTask) Apply(context.Context) (resource.TaskStatus, error)
Apply does stuff
func (*SwitchTask) Cases ¶
func (s *SwitchTask) Cases() []*CaseTask
Cases returns the embedded cases
func (*SwitchTask) Check ¶
func (s *SwitchTask) Check(context.Context, resource.Renderer) (resource.TaskStatus, error)
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