From 555ce986301b29922aa886cfdb6519da5a4f13fc Mon Sep 17 00:00:00 2001 From: Kujtim Date: Tue, 10 Oct 2017 13:02:44 +0200 Subject: [PATCH] Fix bug. --- generator/generate_docker.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/generator/generate_docker.go b/generator/generate_docker.go index 091a209..7165050 100644 --- a/generator/generate_docker.go +++ b/generator/generate_docker.go @@ -184,10 +184,19 @@ func (g *GenerateDocker) addToDockerCompose(name, pth, httpFilePath, grpcFilePat } usedPorts := []string{} for _, v := range g.dockerCompose.Services { - for _, p := range v.(map[interface{}]interface{})["ports"].([]interface{}) { - pt := strings.Split(p.(string), ":") - usedPorts = append(usedPorts, pt[0]) + k, ok := v.(map[interface{}]interface{}) + if ok { + for _, p := range k["ports"].([]interface{}) { + pt := strings.Split(p.(string), ":") + usedPorts = append(usedPorts, pt[0]) + } + } else { + for _, p := range v.(*DockerService).Ports { + pt := strings.Split(p, ":") + usedPorts = append(usedPorts, pt[0]) + } } + } if g.dockerCompose.Services[name] == nil { g.dockerCompose.Services[name] = &DockerService{