github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/terraform/graph_dot.go (about) 1 package terraform 2 3 import "github.com/hashicorp/terraform/dot" 4 5 // GraphNodeDotter can be implemented by a node to cause it to be included 6 // in the dot graph. The Dot method will be called which is expected to 7 // return a representation of this node. 8 type GraphNodeDotter interface { 9 // Dot is called to return the dot formatting for the node. 10 // The first parameter is the title of the node. 11 // The second parameter includes user-specified options that affect the dot 12 // graph. See GraphDotOpts below for details. 13 DotNode(string, *GraphDotOpts) *dot.Node 14 } 15 16 // GraphDotOpts are the options for generating a dot formatted Graph. 17 type GraphDotOpts struct { 18 // Allows some nodes to decide to only show themselves when the user has 19 // requested the "verbose" graph. 20 Verbose bool 21 22 // Highlight Cycles 23 DrawCycles bool 24 25 // How many levels to expand modules as we draw 26 MaxDepth int 27 } 28 29 // GraphDot returns the dot formatting of a visual representation of 30 // the given Terraform graph. 31 func GraphDot(g *Graph, opts *GraphDotOpts) (string, error) { 32 dg, err := NewDebugGraph("root", g, opts) 33 if err != nil { 34 return "", err 35 } 36 return dg.Dot.String(), nil 37 }