Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
type Node struct {
Path []NodeDetail
HandlerFn func(from, to interface{}, path *Node) error
}
Node in the object graph which if present should result in the HandlerFn being invoked where HandlerFn takes a resource objects current and desired states, with the provider responsible for testing equality and subsequent handling of any required changes to the resource.
For example, say you have the following types:
type Car struct {
Make string
Age int
Fuel Fuel
}
type Fuel struct {
Make string
Unleaded bool
}
You can create a change node with handler function for the Unleaded field in a Car object as follows.
handler := func(have, want interface{}, path *change.Node) error {
fmt.Printf("Handle the change here")
}
node := NewNode().Field("Fuel").Field("Unleaded").Handler(handler)
The handler function can be a closure to include additional objects such as API clients, look at the digitalocean package for an example of this.
func NewNode ¶
func NewNode() *Node
NewNode initialises a Node object, with the Path and HandlerFn configured using a builder pattern
func (*Node) Field ¶
Field adds a struct field to the Node path, identified by the name of the struct
func (*Node) Handle ¶
Handle invokes the stored HandlerFn with the current and desired resource states
func (*Node) Handler ¶
Handler adds a HandlerFn to the Node which will be invoked when the Handle() method is called
type NodeDetail ¶
NodeDetail describes an individual node in the path to the target Node above, navigating the object graph via struct fields, map keys or slice/array indices.
type Registry ¶
Registry stores a list of change nodes to be evaluated
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry initialises an empty change Registry with a default logger
func (*Registry) HandleChanges ¶
HandleChanges invokes the change handler for all stored change nodes