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
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
)
|
|
|
|
|
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 {
|
|
|
|
stacks, err := dockerCli.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)
|
|
|
|
err := stacks.Delete(stack, &metav1.DeleteOptions{})
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(dockerCli.Out(), "Failed to remove stack %s: %s\n", stack, err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|