Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 3dbc6ab

Browse files
authored
fix(compose): remove by project name [EE-4916] (#34)
1 parent 4a55294 commit 3dbc6ab

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

compose/compose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func Test_UpAndDown(t *testing.T) {
6767
t.Fatal("container should exist")
6868
}
6969

70-
err = deployer.Remove(ctx, []string{filePathOriginal, filePathOverride}, libstack.Options{})
70+
err = deployer.Remove(ctx, "", []string{filePathOriginal, filePathOverride}, libstack.Options{})
7171
if err != nil {
7272
t.Fatal(err)
7373
}

compose/internal/composeplugin/composeplugin.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func (wrapper *PluginWrapper) Deploy(ctx context.Context, filePaths []string, op
5555
}
5656

5757
// Down stop and remove containers
58-
func (wrapper *PluginWrapper) Remove(ctx context.Context, filePaths []string, options libstack.Options) error {
59-
output, err := wrapper.command(newDownCommand(filePaths), options)
58+
func (wrapper *PluginWrapper) Remove(ctx context.Context, projectName string, filePaths []string, options libstack.Options) error {
59+
output, err := wrapper.command(newDownCommand(projectName, filePaths), options)
6060
if len(output) != 0 {
6161
if err != nil {
6262
return err
@@ -203,8 +203,11 @@ func newUpCommand(filePaths []string, options upOptions) composeCommand {
203203
return newCommand(args, filePaths)
204204
}
205205

206-
func newDownCommand(filePaths []string) composeCommand {
207-
return newCommand([]string{"down", "--remove-orphans"}, filePaths)
206+
func newDownCommand(projectName string, filePaths []string) composeCommand {
207+
cmd := newCommand([]string{"down", "--remove-orphans"}, filePaths)
208+
cmd.WithProjectName(projectName)
209+
210+
return cmd
208211
}
209212

210213
func newPullCommand(filePaths []string) composeCommand {

compose/internal/composeplugin/composeplugin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ services:
101101
t.Fatal("container should exist")
102102
}
103103

104-
err = w.Remove(ctx, []string{filePathOriginal, filePathOverride}, libstack.Options{})
104+
err = w.Remove(ctx, "", []string{filePathOriginal, filePathOverride}, libstack.Options{})
105105
if err != nil {
106106
t.Fatal(err)
107107
}

libstack.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import (
66

77
type Deployer interface {
88
Deploy(ctx context.Context, filePaths []string, options DeployOptions) error
9-
Remove(ctx context.Context, filePaths []string, options Options) error
9+
// Remove stops and removes containers
10+
//
11+
// projectName or filePaths are required
12+
// if projectName is supplied filePaths will be ignored
13+
Remove(ctx context.Context, projectName string, filePaths []string, options Options) error
1014
Pull(ctx context.Context, filePaths []string, options Options) error
1115
Validate(ctx context.Context, filePaths []string, options Options) error
1216
}

0 commit comments

Comments
 (0)