prevent concurrent map write relying on project immutability

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2024-05-29 09:11:59 +02:00 committed by Guillaume Lours
parent bf1dd0c267
commit fd1f73a5e7
1 changed files with 7 additions and 4 deletions

View File

@ -56,13 +56,16 @@ func (s *composeService) restart(ctx context.Context, projectName string, option
} }
// ignore depends_on relations which are not impacted by restarting service or not required // ignore depends_on relations which are not impacted by restarting service or not required
for i, service := range project.Services { project, err = project.WithServicesTransform(func(name string, s types.ServiceConfig) (types.ServiceConfig, error) {
for name, r := range service.DependsOn { for name, r := range s.DependsOn {
if !r.Restart { if !r.Restart {
delete(service.DependsOn, name) delete(s.DependsOn, name)
} }
} }
project.Services[i] = service return s, nil
})
if err != nil {
return err
} }
if len(options.Services) != 0 { if len(options.Services) != 0 {