minor improvement and fix

Signed-off-by: Mehrad Dadar <mehrad.dadar@gmail.com>
This commit is contained in:
Mehrad Dadar 2022-02-25 06:26:05 +03:30
parent 42c3adb236
commit aeb7448449
1 changed files with 11 additions and 9 deletions

View File

@ -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 {