mirror of
https://github.com/docker/compose.git
synced 2025-07-21 12:44:54 +02:00
compose down exit=0 if nothing to remove
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
4cebef1bf1
commit
78b06764a1
@ -90,7 +90,7 @@ func (s *composeService) down(ctx context.Context, projectName string, options a
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !resourceToRemove && len(ops) == 0 {
|
if !resourceToRemove && len(ops) == 0 {
|
||||||
w.Event(progress.NewEvent(projectName, progress.Done, "Warning: No resource found to remove"))
|
fmt.Fprintf(s.stderr(), "Warning: No resource found to remove for project %q.\n", projectName)
|
||||||
}
|
}
|
||||||
|
|
||||||
eg, _ := errgroup.WithContext(ctx)
|
eg, _ := errgroup.WithContext(ctx)
|
||||||
@ -239,7 +239,7 @@ func (s *composeService) removeContainers(ctx context.Context, w progress.Writer
|
|||||||
func (s *composeService) getProjectWithResources(ctx context.Context, containers Containers, projectName string) (*types.Project, error) {
|
func (s *composeService) getProjectWithResources(ctx context.Context, containers Containers, projectName string) (*types.Project, error) {
|
||||||
containers = containers.filter(isNotOneOff)
|
containers = containers.filter(isNotOneOff)
|
||||||
project, err := s.projectFromName(containers, projectName)
|
project, err := s.projectFromName(containers, projectName)
|
||||||
if err != nil {
|
if err != nil && !api.IsNotFoundError(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
pkg/e2e/compose_down_test.go
Normal file
34
pkg/e2e/compose_down_test.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 Docker Compose CLI authors
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/v3/icmd"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDown(t *testing.T) {
|
||||||
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
|
|
||||||
|
const projectName = "e2e-down"
|
||||||
|
|
||||||
|
t.Run("no resource to remove", func(t *testing.T) {
|
||||||
|
res := c.RunDockerOrExitError("compose", "--project-name", projectName, "down")
|
||||||
|
res.Assert(t, icmd.Expected{ExitCode: 0, Err: `No resource found to remove for project "e2e-down"`})
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user