From c5f44cf3402c96e86269939684180234884816f7 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 21 Oct 2021 15:10:43 +0200 Subject: [PATCH] feat: show undploy overview --- cli/app/deploy.go | 6 +++--- cli/app/undeploy.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cli/app/deploy.go b/cli/app/deploy.go index a34a54330..096a88d0d 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -123,7 +123,7 @@ recipes. logrus.Fatal(err) } - if err := DeployOverview(app, version); err != nil { + if err := DeployOverview(app, version, "continue with deployment?"); err != nil { logrus.Fatal(err) } @@ -148,7 +148,7 @@ recipes. } // DeployOverview shows a deployment overview -func DeployOverview(app config.App, version string) error { +func DeployOverview(app config.App, version, message string) error { tableCol := []string{"server", "compose", "domain", "stack", "version"} table := abraFormatter.CreateTable(tableCol) @@ -167,7 +167,7 @@ func DeployOverview(app config.App, version string) error { response := false prompt := &survey.Confirm{ - Message: "continue with deployment?", + Message: message, } if err := survey.AskOne(prompt, &response); err != nil { diff --git a/cli/app/undeploy.go b/cli/app/undeploy.go index 8652c75b4..035fca684 100644 --- a/cli/app/undeploy.go +++ b/cli/app/undeploy.go @@ -22,12 +22,28 @@ volumes as eligiblef or pruning once undeployed. `, Action: func(c *cli.Context) error { app := internal.ValidateApp(c) + stackName := app.StackName() cl, err := client.New(app.Server) if err != nil { logrus.Fatal(err) } + logrus.Debugf("checking whether '%s' is already deployed", stackName) + + isDeployed, deployedVersion, err := stack.IsDeployed(c.Context, cl, stackName) + if err != nil { + logrus.Fatal(err) + } + + if !isDeployed { + logrus.Fatalf("'%s' is not deployed?", stackName) + } + + if err := DeployOverview(app, deployedVersion, "continue with undeploy?"); err != nil { + logrus.Fatal(err) + } + rmOpts := stack.Remove{Namespaces: []string{app.StackName()}} if err := stack.RunRemove(c.Context, cl, rmOpts); err != nil { logrus.Fatal(err)