Documentation
¶
Overview ¶
Package graph provides an implement of cfn.Graph and can be used to graph dependencies between elements of a CloudFormation template
Example (Get) ¶
package main
import (
"fmt"
"github.com/aws-cloudformation/rain/cfn/graph"
)
func main() {
g := graph.New()
g.Add("foo", "bar", "baz")
g.Add("bar", "quux")
g.Add("baz", "foo") // Circular dependencies are fine
fmt.Println(g.Get("foo"))
fmt.Println(g.Get("bar"))
fmt.Println(g.Get("baz"))
}
Output: [bar baz] [quux] [foo]
Example (GetReverse) ¶
package main
import (
"fmt"
"github.com/aws-cloudformation/rain/cfn/graph"
)
func main() {
g := graph.New()
g.Add("foo", "bar", "baz")
g.Add("bar", "quux", "baz")
g.Add("baz", "foo") // Circular dependencies are fine
fmt.Println(g.GetReverse("foo"))
fmt.Println(g.GetReverse("bar"))
fmt.Println(g.GetReverse("baz"))
}
Output: [baz] [foo] [bar foo]
Example (Nodes) ¶
package main
import (
"fmt"
"github.com/aws-cloudformation/rain/cfn/graph"
)
func main() {
g := graph.New()
g.Add("Cake", "Eggs", "Butter")
g.Add("Eggs", "Chicken")
g.Add("Dinner", "Chicken", "Cake")
fmt.Println(g.Nodes())
}
Output: [Butter Chicken Eggs Cake Dinner]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
func (*Graph) Add ¶
func (g *Graph) Add(item interface{}, links ...interface{})
Add creates a link between two nodes in the graph
func (Graph) Get ¶
func (g Graph) Get(item interface{}) []interface{}
Get returns all nodes that are connected to the item that you pass in.
func (Graph) GetReverse ¶
func (g Graph) GetReverse(item interface{}) []interface{}
GetReverse returns all nodes that connect to the item that you pass in.
Click to show internal directories.
Click to hide internal directories.