From aeb74484496bc17a03c9ed8dd53b38d481f71e1c Mon Sep 17 00:00:00 2001 From: Mehrad Dadar Date: Fri, 25 Feb 2022 06:26:05 +0330 Subject: [PATCH] minor improvement and fix Signed-off-by: Mehrad Dadar --- pkg/compose/compose.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/compose/compose.go b/pkg/compose/compose.go index 780aa459e..f71978e2b 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -102,16 +102,18 @@ func (s *composeService) projectFromName(containers Containers, projectName stri if len(containers) == 0 { return project, errors.New("no such project: " + projectName) } - set := map[string]types.ServiceConfig{} + set := map[string]*types.ServiceConfig{} for _, c := range containers { - sc := types.ServiceConfig{ - Name: c.Labels[api.ServiceLabel], - Image: c.Image, - Labels: c.Labels, + serviceLabel := c.Labels[api.ServiceLabel] + _, ok := set[serviceLabel] + if !ok { + set[serviceLabel] = &types.ServiceConfig{ + Name: serviceLabel, + Image: c.Image, + Labels: c.Labels, + } } - sc.Scale++ - set[sc.Name] = sc - + set[serviceLabel].Scale++ } for _, service := range set { dependencies := service.Labels[api.DependenciesLabel] @@ -129,7 +131,7 @@ func (s *composeService) projectFromName(containers Containers, projectName stri service.DependsOn[dependency] = types.ServiceDependency{Condition: condition} } } - project.Services = append(project.Services, service) + project.Services = append(project.Services, *service) } SERVICES: for _, qs := range services {