refactor/fix: deploy/upgrade/rollback

See coop-cloud/abra#461
This commit is contained in:
2025-01-01 19:15:22 +01:00
parent 5975be6870
commit b0cd8ccbb9
85 changed files with 783 additions and 7118 deletions

View File

@ -2,9 +2,10 @@ package internal
var (
// NOTE(d1): global
Debug bool
NoInput bool
Offline bool
Debug bool
NoInput bool
Offline bool
IgnoreEnvVersion bool
// NOTE(d1): sub-command specific
Chaos bool

View File

@ -68,11 +68,17 @@ func NewVersionOverview(
{"RECIPE", app.Recipe.Name},
{"SERVER", server},
{"CONFIG", deployConfig},
{"CURRENT DEPLOYMENT", "---"},
{"VERSION", deployedVersion},
{"CHAOS ", deployedChaosVersion},
{upperKind, "---"},
{"VERSION", toDeployVersion},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Domain)), "---"},
{"OLD", app.Recipe.EnvVersion},
{"NEW", toDeployVersion},
}
overview := formatter.CreateOverview(
@ -119,7 +125,9 @@ func DeployOverview(
deployedVersion string,
deployedChaosVersion string,
toDeployVersion,
toDeployChaosVersion string) error {
toDeployChaosVersion string,
toWriteVersion string,
) error {
deployConfig := "compose.yml"
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
deployConfig = composeFiles
@ -154,6 +162,10 @@ func DeployOverview(
{"NEW DEPLOYMENT", "---"},
{"VERSION", toDeployVersion},
{"CHAOS", toDeployChaosVersion},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
{"CURRENT VERSION", app.Recipe.EnvVersion},
{"NEW VERSION", toWriteVersion},
}
overview := formatter.CreateOverview("DEPLOY OVERVIEW", rows)
@ -210,9 +222,14 @@ func UndeployOverview(
{"RECIPE", app.Recipe.Name},
{"SERVER", server},
{"CONFIG", deployConfig},
{"CURRENT DEPLOYMENT", "---"},
{"DEPLOYED", version},
{"CHAOS", chaosVersion},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
{"CURRENT VERSION", app.Recipe.EnvVersion},
{"NEW VERSION", version},
}
overview := formatter.CreateOverview("UNDEPLOY OVERVIEW", rows)

11
cli/internal/ensure.go Normal file
View File

@ -0,0 +1,11 @@
package internal
import "coopcloud.tech/abra/pkg/recipe"
func GetEnsureContext() recipe.EnsureContext {
return recipe.EnsureContext{
Chaos,
Offline,
IgnoreEnvVersion,
}
}

View File

@ -1,18 +0,0 @@
package internal
import (
"os"
"coopcloud.tech/abra/pkg/log"
"github.com/urfave/cli/v3"
)
// ShowSubcommandHelpAndError exits the program on error, logs the error to the
// terminal, and shows the help command.
func ShowSubcommandHelpAndError(cmd *cli.Command, err interface{}) {
if err2 := cli.ShowSubcommandHelp(cmd); err2 != nil {
log.Error(err2)
}
log.Error(err)
os.Exit(1)
}