mirror of https://github.com/docker/compose.git
Fixed issue when project name contains dashes (`-`)
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
This commit is contained in:
parent
7840a92c40
commit
5eaafe4237
|
@ -42,10 +42,19 @@ func (s *composeService) Viz(_ context.Context, project *types.Project, opts api
|
|||
|
||||
// build graphviz graph
|
||||
var graphBuilder strings.Builder
|
||||
graphBuilder.WriteString("digraph " + project.Name + " {\n")
|
||||
|
||||
// graph name
|
||||
graphBuilder.WriteString("digraph ")
|
||||
writeQuoted(&graphBuilder, project.Name)
|
||||
graphBuilder.WriteString(" {\n")
|
||||
|
||||
// graph layout
|
||||
// dot is the perfect layout for this use case since graph is directed and hierarchical
|
||||
graphBuilder.WriteString(opts.Indentation + "layout=dot;\n")
|
||||
|
||||
addNodes(&graphBuilder, graph, &opts)
|
||||
graphBuilder.WriteByte('\n')
|
||||
|
||||
addEdges(&graphBuilder, graph, &opts)
|
||||
graphBuilder.WriteString("}\n")
|
||||
|
||||
|
|
|
@ -82,6 +82,20 @@ func TestViz(t *testing.T) {
|
|||
"external": nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "With host IP",
|
||||
Image: "user/image-name",
|
||||
DependsOn: map[string]types.ServiceDependency{
|
||||
"service1": {},
|
||||
},
|
||||
Ports: []types.ServicePortConfig{
|
||||
{
|
||||
Published: "8888",
|
||||
Target: 8080,
|
||||
HostIP: "127.0.0.1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Networks: types.Networks{
|
||||
"internal": types.NetworkConfig{},
|
||||
|
@ -121,7 +135,7 @@ func TestViz(t *testing.T) {
|
|||
assert.NotContains(t, graphStr, "\n ", graphStr)
|
||||
|
||||
// check digraph name
|
||||
assert.Contains(t, graphStr, "digraph "+project.Name, graphStr)
|
||||
assert.Contains(t, graphStr, "digraph \""+project.Name+"\"", graphStr)
|
||||
|
||||
// check nodes
|
||||
for _, service := range project.Services {
|
||||
|
@ -179,7 +193,7 @@ func TestViz(t *testing.T) {
|
|||
assert.NotContains(t, graphStr, "\n\t\t", graphStr)
|
||||
|
||||
// check digraph name
|
||||
assert.Contains(t, graphStr, "digraph "+project.Name, graphStr)
|
||||
assert.Contains(t, graphStr, "digraph \""+project.Name+"\"", graphStr)
|
||||
|
||||
// check nodes
|
||||
for _, service := range project.Services {
|
||||
|
|
Loading…
Reference in New Issue