Esempio n. 1
0
//  takes a Terraform Graph and build the internal debug graph
func (dg *DebugGraph) build(g *Graph) error {
	if dg == nil {
		return nil
	}
	dg.Lock()
	defer dg.Unlock()

	dg.Dot = dot.NewGraph(map[string]string{
		"compound": "true",
		"newrank":  "true",
	})
	dg.Dot.Directed = true

	if dg.dotOpts == nil {
		dg.dotOpts = &GraphDotOpts{
			DrawCycles: true,
			MaxDepth:   -1,
			Verbose:    true,
		}
	}

	err := dg.buildSubgraph("root", g, 0)
	if err != nil {
		return err
	}

	return nil
}
Esempio n. 2
0
// GraphDot returns the dot formatting of a visual representation of
// the given Terraform graph.
func GraphDot(g *Graph, opts *GraphDotOpts) (string, error) {
	dg := dot.NewGraph(map[string]string{
		"compound": "true",
		"newrank":  "true",
	})
	dg.Directed = true

	err := graphDotSubgraph(dg, "root", g, opts, 0)
	if err != nil {
		return "", err
	}

	return dg.String(), nil
}