コード例 #1
0
func graphDotAddRoot(buf *bytes.Buffer, n *depgraph.Noun) {
	buf.WriteString(fmt.Sprintf("\t\"%s\" [shape=circle];\n", "root"))

	for _, e := range n.Edges() {
		target := e.Tail()
		buf.WriteString(fmt.Sprintf(
			"\t\"%s\" -> \"%s\";\n",
			"root",
			target))
	}
}
コード例 #2
0
ファイル: graph_dot.go プロジェクト: packetloop/terraform
func graphWriteEdges(
	buf *bytes.Buffer, n *depgraph.Noun, opts *GraphDotOpts) {
	tab := strings.Repeat("\t", opts.depth+1)

	uniqueName := graphUniqueName(n, opts)
	var ltail string
	if _, ok := n.Meta.(*GraphNodeModule); ok && graphExpand(opts) {
		ltail = "cluster_" + uniqueName
		uniqueName = uniqueName + "_hidden"
	}

	for _, e := range n.Edges() {
		target := e.Tail()
		targetN := target.(*depgraph.Noun)
		uniqueTarget := graphUniqueName(targetN, opts)

		var lhead string
		if _, ok := targetN.Meta.(*GraphNodeModule); ok && graphExpand(opts) {
			lhead = "cluster_" + uniqueTarget
			uniqueTarget = uniqueTarget + "_hidden"
		}

		var attrs string
		if lhead != "" || ltail != "" {
			var attrList []string
			if lhead != "" {
				attrList = append(attrList, fmt.Sprintf(
					"lhead=\"%s\"", lhead))
			}
			if ltail != "" {
				attrList = append(attrList, fmt.Sprintf(
					"ltail=\"%s\"", ltail))
			}

			attrs = fmt.Sprintf(" [%s]", strings.Join(attrList, ","))
		}

		buf.WriteString(fmt.Sprintf(
			"%s\"%s\" -> \"%s\"%s;\n",
			tab,
			uniqueName,
			uniqueTarget,
			attrs))
	}
}