From 44b4bc01afabd1996d32b0cba61c321b17167401 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Wed, 2 Dec 2020 11:12:22 +0100 Subject: [PATCH 1/2] =?UTF-8?q?In=20`compose=20down`=20progress=20display:?= =?UTF-8?q?=20prefix=20container=20names=20with=20=E2=80=9CContainer?= =?UTF-8?q?=E2=80=9D,=20same=20as=20Services,=20Networks,=20homogeneous=20?= =?UTF-8?q?with=20`compose=20up`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- local/compose.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/local/compose.go b/local/compose.go index ef6d96f20..1434f3f2d 100644 --- a/local/compose.go +++ b/local/compose.go @@ -261,28 +261,28 @@ func (s *composeService) Down(ctx context.Context, projectName string) error { } func (s *composeService) removeContainers(ctx context.Context, w progress.Writer, eg *errgroup.Group, filter filters.Args) error { - cnts, err := s.apiClient.ContainerList(ctx, moby.ContainerListOptions{ + containers, err := s.apiClient.ContainerList(ctx, moby.ContainerListOptions{ Filters: filter, }) if err != nil { return err } - for _, c := range cnts { + for _, c := range containers { eg.Go(func() error { - cName := getContainerName(c) - w.Event(progress.StoppingEvent(cName)) + eventName := "Container " + getContainerName(c) + w.Event(progress.StoppingEvent(eventName)) err := s.apiClient.ContainerStop(ctx, c.ID, nil) if err != nil { - w.Event(progress.ErrorMessageEvent(cName, "Error while Stopping")) + w.Event(progress.ErrorMessageEvent(eventName, "Error while Stopping")) return err } - w.Event(progress.RemovingEvent(cName)) + w.Event(progress.RemovingEvent(eventName)) err = s.apiClient.ContainerRemove(ctx, c.ID, moby.ContainerRemoveOptions{}) if err != nil { - w.Event(progress.ErrorMessageEvent(cName, "Error while Removing")) + w.Event(progress.ErrorMessageEvent(eventName, "Error while Removing")) return err } - w.Event(progress.RemovedEvent(cName)) + w.Event(progress.RemovedEvent(eventName)) return nil }) } From 56511a4a3a0b81e49747ea6e31b18499eb35f6a4 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 3 Dec 2020 15:47:19 +0100 Subject: [PATCH 2/2] renaming Signed-off-by: Guillaume Tardif --- local/compose.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/local/compose.go b/local/compose.go index 1434f3f2d..2ba976c5b 100644 --- a/local/compose.go +++ b/local/compose.go @@ -267,17 +267,17 @@ func (s *composeService) removeContainers(ctx context.Context, w progress.Writer if err != nil { return err } - for _, c := range containers { + for _, container := range containers { eg.Go(func() error { - eventName := "Container " + getContainerName(c) + eventName := "Container " + getContainerName(container) w.Event(progress.StoppingEvent(eventName)) - err := s.apiClient.ContainerStop(ctx, c.ID, nil) + err := s.apiClient.ContainerStop(ctx, container.ID, nil) if err != nil { w.Event(progress.ErrorMessageEvent(eventName, "Error while Stopping")) return err } w.Event(progress.RemovingEvent(eventName)) - err = s.apiClient.ContainerRemove(ctx, c.ID, moby.ContainerRemoveOptions{}) + err = s.apiClient.ContainerRemove(ctx, container.ID, moby.ContainerRemoveOptions{}) if err != nil { w.Event(progress.ErrorMessageEvent(eventName, "Error while Removing")) return err @@ -290,7 +290,7 @@ func (s *composeService) removeContainers(ctx context.Context, w progress.Writer } func (s *composeService) projectFromContainerLabels(ctx context.Context, projectName string) (*types.Project, error) { - cnts, err := s.apiClient.ContainerList(ctx, moby.ContainerListOptions{ + containers, err := s.apiClient.ContainerList(ctx, moby.ContainerListOptions{ Filters: filters.NewArgs( projectFilter(projectName), ), @@ -298,10 +298,10 @@ func (s *composeService) projectFromContainerLabels(ctx context.Context, project if err != nil { return nil, err } - if len(cnts) == 0 { + if len(containers) == 0 { return nil, nil } - options, err := loadProjectOptionsFromLabels(cnts[0]) + options, err := loadProjectOptionsFromLabels(containers[0]) if err != nil { return nil, err } @@ -309,9 +309,9 @@ func (s *composeService) projectFromContainerLabels(ctx context.Context, project fakeProject := &types.Project{ Name: projectName, } - for _, c := range cnts { + for _, container := range containers { fakeProject.Services = append(fakeProject.Services, types.ServiceConfig{ - Name: c.Labels[serviceLabel], + Name: container.Labels[serviceLabel], }) } return fakeProject, nil