feat: add pre-deploy overview
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2021-10-12 13:25:23 +02:00
parent 4235e06943
commit d804276cf2
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 36 additions and 0 deletions

View File

@ -2,11 +2,14 @@ package app
import (
"fmt"
"strings"
abraFormatter "coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/client"
stack "coopcloud.tech/abra/pkg/client/stack"
"coopcloud.tech/abra/pkg/config"
"github.com/AlecAivazis/survey/v2"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -47,6 +50,10 @@ var appDeployCommand = &cli.Command{
logrus.Fatal(err)
}
if err := DeployOverview(app); err != nil {
logrus.Fatal(err)
}
if err := stack.RunDeploy(cl, deployOpts, compose); err != nil {
logrus.Fatal(err)
}
@ -66,3 +73,32 @@ var appDeployCommand = &cli.Command{
}
},
}
// DeployOverview shows a deployment overview
func DeployOverview(app config.App) error {
tableCol := []string{"server", "compose", "domain", "stack", "version"}
table := abraFormatter.CreateTable(tableCol)
deployConfig := "compose.yml"
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
deployConfig = strings.Join(strings.Split(composeFiles, ":"), "\n")
}
table.Append([]string{app.Server, deployConfig, app.Domain, app.StackName(), "unknown"})
table.Render()
response := false
prompt := &survey.Confirm{
Message: "continue with deployment?",
}
if err := survey.AskOne(prompt, &response); err != nil {
return err
}
if !response {
logrus.Fatal("exiting as requested")
}
return nil
}