MCPcopy
hub / github.com/docker/compose / addNodes

Function addNodes

pkg/compose/viz.go:66–118  ·  view source on GitHub ↗

addNodes adds the corresponding graphviz representation of all the nodes in the given graph to the graphBuilder returns the same graphBuilder

(graphBuilder *strings.Builder, graph vizGraph, projectName string, opts *api.VizOptions)

Source from the content-addressed store, hash-verified

64// addNodes adds the corresponding graphviz representation of all the nodes in the given graph to the graphBuilder
65// returns the same graphBuilder
66func addNodes(graphBuilder *strings.Builder, graph vizGraph, projectName string, opts *api.VizOptions) *strings.Builder {
67 for serviceNode := range graph {
68 // write:
69 // "service name" [style="filled" label<<font point-size="15">service name</font>
70 graphBuilder.WriteString(opts.Indentation)
71 writeQuoted(graphBuilder, serviceNode.Name)
72 graphBuilder.WriteString(" [style=\"filled\" label=<<font point-size=\"15\">")
73 graphBuilder.WriteString(serviceNode.Name)
74 graphBuilder.WriteString("</font>")
75
76 if opts.IncludeNetworks && len(serviceNode.Networks) > 0 {
77 graphBuilder.WriteString("<font point-size=\"10\">")
78 graphBuilder.WriteString("<br/><br/><b>Networks:</b>")
79 for _, networkName := range serviceNode.NetworksByPriority() {
80 graphBuilder.WriteString("<br/>")
81 graphBuilder.WriteString(networkName)
82 }
83 graphBuilder.WriteString("</font>")
84 }
85
86 if opts.IncludePorts && len(serviceNode.Ports) > 0 {
87 graphBuilder.WriteString("<font point-size=\"10\">")
88 graphBuilder.WriteString("<br/><br/><b>Ports:</b>")
89 for _, portConfig := range serviceNode.Ports {
90 graphBuilder.WriteString("<br/>")
91 if portConfig.HostIP != "" {
92 graphBuilder.WriteString(portConfig.HostIP)
93 graphBuilder.WriteByte(':')
94 }
95 graphBuilder.WriteString(portConfig.Published)
96 graphBuilder.WriteByte(':')
97 graphBuilder.WriteString(strconv.Itoa(int(portConfig.Target)))
98 graphBuilder.WriteString(" (")
99 graphBuilder.WriteString(portConfig.Protocol)
100 graphBuilder.WriteString(", ")
101 graphBuilder.WriteString(portConfig.Mode)
102 graphBuilder.WriteString(")")
103 }
104 graphBuilder.WriteString("</font>")
105 }
106
107 if opts.IncludeImageName {
108 graphBuilder.WriteString("<font point-size=\"10\">")
109 graphBuilder.WriteString("<br/><br/><b>Image:</b><br/>")
110 graphBuilder.WriteString(api.GetImageNameOrDefault(*serviceNode, projectName))
111 graphBuilder.WriteString("</font>")
112 }
113
114 graphBuilder.WriteString(">];\n")
115 }
116
117 return graphBuilder
118}
119
120// addEdges adds the corresponding graphviz representation of all edges in the given graph to the graphBuilder
121// returns the same graphBuilder

Callers 1

VizMethod · 0.85

Calls 2

GetImageNameOrDefaultFunction · 0.92
writeQuotedFunction · 0.85

Tested by

no test coverage detected