2017-11-20 09:30:52 -05:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2017-12-04 06:30:39 -05:00
|
|
|
"github.com/docker/cli/cli/command/stack/options"
|
2017-11-20 09:30:52 -05:00
|
|
|
)
|
|
|
|
|
2017-12-04 06:30:39 -05:00
|
|
|
// RunRemove is the kubernetes implementation of docker stack remove
|
|
|
|
func RunRemove(dockerCli *KubeCli, opts options.Remove) error {
|
2018-04-09 09:07:11 -04:00
|
|
|
composeClient, err := dockerCli.composeClient()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
stacks, err := composeClient.Stacks()
|
2017-11-20 09:30:52 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-12-04 06:30:39 -05:00
|
|
|
for _, stack := range opts.Namespaces {
|
2017-11-20 09:30:52 -05:00
|
|
|
fmt.Fprintf(dockerCli.Out(), "Removing stack: %s\n", stack)
|
2018-01-31 09:37:14 -05:00
|
|
|
err := stacks.Delete(stack)
|
2017-11-20 09:30:52 -05:00
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(dockerCli.Out(), "Failed to remove stack %s: %s\n", stack, err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|