mirror of https://github.com/docker/compose.git
Merge pull request #1260 from gtardif/down_warn_nothing_to_remove
Down warning when nothing to remove
This commit is contained in:
commit
c663ea6ffe
|
@ -84,6 +84,9 @@ func (w *ttyWriter) Event(e Event) {
|
|||
} else {
|
||||
e.startTime = time.Now()
|
||||
e.spinner = newSpinner()
|
||||
if e.Status == Done || e.Status == Error {
|
||||
e.stop()
|
||||
}
|
||||
w.events[e.ID] = e
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import (
|
|||
|
||||
func (s *composeService) Down(ctx context.Context, projectName string, options compose.DownOptions) error {
|
||||
w := progress.ContextWriter(ctx)
|
||||
resourceToRemove := false
|
||||
|
||||
if options.Project == nil {
|
||||
project, err := s.projectFromContainerLabels(ctx, projectName)
|
||||
|
@ -51,6 +52,9 @@ func (s *composeService) Down(ctx context.Context, projectName string, options c
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(containers) > 0 {
|
||||
resourceToRemove = true
|
||||
}
|
||||
|
||||
err = InReverseDependencyOrder(ctx, options.Project, func(c context.Context, service types.ServiceConfig) error {
|
||||
serviceContainers, others := containers.split(isService(service.Name))
|
||||
|
@ -80,12 +84,16 @@ func (s *composeService) Down(ctx context.Context, projectName string, options c
|
|||
|
||||
eg, _ := errgroup.WithContext(ctx)
|
||||
for _, n := range networks {
|
||||
resourceToRemove = true
|
||||
networkID := n.ID
|
||||
networkName := n.Name
|
||||
eg.Go(func() error {
|
||||
return s.ensureNetworkDown(ctx, networkID, networkName)
|
||||
})
|
||||
}
|
||||
if !resourceToRemove {
|
||||
w.Event(progress.NewEvent(projectName, progress.Done, "Warning: No resource found to remove"))
|
||||
}
|
||||
return eg.Wait()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue