refactor: use app getting instead of boilerplate

This commit is contained in:
2021-09-05 23:17:35 +02:00
parent 48bcc9cb36
commit d4333c2dc0
18 changed files with 111 additions and 266 deletions

View File

@ -6,7 +6,6 @@ import (
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/client"
stack "coopcloud.tech/abra/pkg/client/stack"
"coopcloud.tech/abra/pkg/config"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -21,26 +20,15 @@ vigilant, as your swarm installation will consider any previously attached
volumes as eligiblef or pruning once undeployed.
`,
Action: func(c *cli.Context) error {
appName := internal.ValidateAppNameArg(c)
appFiles, err := config.LoadAppFiles("")
if err != nil {
logrus.Fatal(err)
}
appEnv, err := config.GetApp(appFiles, appName)
if err != nil {
logrus.Fatal(err)
}
app := internal.ValidateApp(c)
ctx := context.Background()
host := appFiles[appName].Server
cl, err := client.New(host)
cl, err := client.New(app.Server)
if err != nil {
logrus.Fatal(err)
}
rmOpts := stack.Remove{Namespaces: []string{appEnv.StackName()}}
rmOpts := stack.Remove{Namespaces: []string{app.StackName()}}
if err := stack.RunRemove(ctx, cl, rmOpts); err != nil {
logrus.Fatal(err)
}