mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Only kill running containers
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
740276f550
commit
cf7319fc6e
@ -43,6 +43,7 @@ func getStringFlags() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert transforms standalone docker-compose args into CLI plugin compliant ones
|
||||||
func Convert(args []string) []string {
|
func Convert(args []string) []string {
|
||||||
var rootFlags []string
|
var rootFlags []string
|
||||||
command := []string{compose.PluginName}
|
command := []string{compose.PluginName}
|
||||||
|
@ -42,7 +42,7 @@ func (s *composeService) kill(ctx context.Context, project *types.Project, optio
|
|||||||
}
|
}
|
||||||
|
|
||||||
var containers Containers
|
var containers Containers
|
||||||
containers, err := s.getContainers(ctx, project.Name, oneOffInclude, true, services...)
|
containers, err := s.getContainers(ctx, project.Name, oneOffInclude, false, services...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,9 @@ func TestKillAll(t *testing.T) {
|
|||||||
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{testService("service1"), testService("service2")}}
|
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{testService("service1"), testService("service2")}}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
api.EXPECT().ContainerList(ctx, projectFilterListOpt()).Return(
|
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{
|
||||||
|
Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))),
|
||||||
|
}).Return(
|
||||||
[]moby.Container{testContainer("service1", "123", false), testContainer("service1", "456", false), testContainer("service2", "789", false)}, nil)
|
[]moby.Container{testContainer("service1", "123", false), testContainer("service1", "456", false), testContainer("service2", "789", false)}, nil)
|
||||||
api.EXPECT().ContainerKill(anyCancellableContext(), "123", "").Return(nil)
|
api.EXPECT().ContainerKill(anyCancellableContext(), "123", "").Return(nil)
|
||||||
api.EXPECT().ContainerKill(anyCancellableContext(), "456", "").Return(nil)
|
api.EXPECT().ContainerKill(anyCancellableContext(), "456", "").Return(nil)
|
||||||
@ -64,9 +66,7 @@ func TestKillSignal(t *testing.T) {
|
|||||||
|
|
||||||
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{testService(serviceName)}}
|
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{testService(serviceName)}}
|
||||||
listOptions := moby.ContainerListOptions{
|
listOptions := moby.ContainerListOptions{
|
||||||
Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)),
|
Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)), serviceFilter(serviceName)),
|
||||||
serviceFilter(serviceName)),
|
|
||||||
All: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user