decentral1se
da049ad69a
All checks were successful
continuous-integration/drone/push Build is passing
Part of coop-cloud/go-abra#57.
49 lines
1009 B
Go
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
|
|
},
|
|
}
|