From 8eb973391407ec5e0e76c55e6aa816ee4cffc3ff Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 14 Dec 2020 18:03:25 +0100 Subject: [PATCH] No need to support service `container_name` in this PR, will do separately, minor cleanup Signed-off-by: Guillaume Tardif --- local/compose/convergence.go | 4 ---- local/compose/create.go | 5 +---- local/compose/run.go | 12 ++---------- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/local/compose/convergence.go b/local/compose/convergence.go index 8128d8b7d..53df364db 100644 --- a/local/compose/convergence.go +++ b/local/compose/convergence.go @@ -61,10 +61,6 @@ func (s *composeService) ensureService(ctx context.Context, project *types.Proje for i := 0; i < missing; i++ { number := next + i name := fmt.Sprintf("%s_%s_%d", project.Name, service.Name, number) - if len(service.ContainerName) > 0 { - name = service.ContainerName - } - eg.Go(func() error { return s.createContainer(ctx, project, service, name, number) }) diff --git a/local/compose/create.go b/local/compose/create.go index 26bea4c2b..18fa1b535 100644 --- a/local/compose/create.go +++ b/local/compose/create.go @@ -105,10 +105,7 @@ func getContainerCreateOptions(p *types.Project, s types.ServiceConfig, number i labels[projectLabel] = p.Name labels[serviceLabel] = s.Name labels[versionLabel] = ComposeVersion - if _, ok := s.Labels[oneoffLabel]; ok { - labels[oneoffLabel] = s.Labels[oneoffLabel] - labels[slugLabel] = s.Labels[slugLabel] - } else { + if _, ok := s.Labels[oneoffLabel]; !ok { labels[oneoffLabel] = "False" } labels[configHashLabel] = hash diff --git a/local/compose/run.go b/local/compose/run.go index 065efcb8f..a1b5ef6bd 100644 --- a/local/compose/run.go +++ b/local/compose/run.go @@ -34,25 +34,19 @@ func (s *composeService) CreateOneOffContainer(ctx context.Context, project *typ if err != nil { return "", err } - err = s.ensureImagesExists(ctx, project) - if err != nil { + if err = s.ensureImagesExists(ctx, project); err != nil { return "", err } - if err := s.ensureProjectNetworks(ctx, project); err != nil { return "", err } - if err := s.ensureProjectVolumes(ctx, project); err != nil { return "", err } - // ensure required services are up and running before creating the oneoff container - err = s.ensureRequiredServices(ctx, project, service) - if err != nil { + if err = s.ensureRequiredServices(ctx, project, service); err != nil { return "", err } - //apply options to service config updateOneOffServiceConfig(&service, project.Name, opts) err = s.createContainer(ctx, project, service, service.ContainerName, 1) @@ -120,10 +114,8 @@ func (s *composeService) Run(ctx context.Context, container string, detach bool) func updateOneOffServiceConfig(service *types.ServiceConfig, projectName string, opts compose.RunOptions) { if len(opts.Command) > 0 { - // custom command to run service.Command = opts.Command } - //service.Environment = opts.Environment slug := moby.GenerateRandomID() service.Scale = 1 service.ContainerName = fmt.Sprintf("%s_%s_run_%s", projectName, service.Name, moby.TruncateID(slug))