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"
|
2018-05-30 09:20:44 -04:00
|
|
|
"github.com/pkg/errors"
|
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
|
|
|
|
}
|
2018-04-09 09:13:16 -04:00
|
|
|
stacks, err := composeClient.Stacks(false)
|
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-05-30 09:20:44 -04:00
|
|
|
if err := stacks.Delete(stack); err != nil {
|
|
|
|
return errors.Wrapf(err, "Failed to remove stack %s", stack)
|
2017-11-20 09:30:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|