abra/cli/app/undeploy.go
decentral1se da049ad69a
All checks were successful
continuous-integration/drone/push Build is passing
fix: drop swarmkit/etcd dep
Part of coop-cloud/go-abra#57.
2021-09-04 21:08:14 +02:00

49 lines
1009 B
Go

package app
import (
"context"
"errors"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/client"
stack "coopcloud.tech/abra/client/stack"
"coopcloud.tech/abra/config"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
var appUndeployCommand = &cli.Command{
Name: "undeploy",
Usage: "Undeploy an app",
Action: func(c *cli.Context) error {
appName := c.Args().First()
if appName == "" {
internal.ShowSubcommandHelpAndError(c, errors.New("no app name provided"))
}
appFiles, err := config.LoadAppFiles("")
if err != nil {
logrus.Fatal(err)
}
appEnv, err := config.GetApp(appFiles, appName)
if err != nil {
logrus.Fatal(err)
}
ctx := context.Background()
host := appFiles[appName].Server
cl, err := client.NewClientWithContext(host)
if err != nil {
logrus.Fatal(err)
}
rmOpts := stack.Remove{Namespaces: []string{appEnv.StackName()}}
if err := stack.RunRemove(ctx, cl, rmOpts); err != nil {
logrus.Fatal(err)
}
return nil
},
}