fix: more env version write tests

See toolshed/organising#661
This commit is contained in:
2025-01-02 19:42:55 +01:00
parent f07c64f7b8
commit 3a71dc47f8
15 changed files with 661 additions and 45 deletions

View File

@ -10,6 +10,7 @@ import (
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/tagcmp"
"github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/lipgloss"
@ -70,15 +71,15 @@ func NewVersionOverview(
{"CONFIG", deployConfig},
{"CURRENT DEPLOYMENT", "---"},
{"VERSION", deployedVersion},
{"CHAOS ", deployedChaosVersion},
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
{"CHAOS ", formatter.BoldDirtyDefault(deployedChaosVersion)},
{upperKind, "---"},
{"VERSION", toDeployVersion},
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Domain)), "---"},
{"CURRENT VERSION", app.Recipe.EnvVersion},
{"NEW VERSION", toDeployVersion},
{"CURRENT VERSION", formatter.BoldDirtyDefault(app.Recipe.EnvVersion)},
{"NEW VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
}
overview := formatter.CreateOverview(
@ -143,10 +144,23 @@ func DeployOverview(
domain = config.NO_DOMAIN_DEFAULT
}
deployedChaosVersion = formatter.BoldDirtyDefault(deployedChaosVersion)
if app.Recipe.Dirty {
toDeployChaosVersion = formatter.BoldDirtyDefault(toDeployChaosVersion)
toWriteVersion = formatter.AddDirtyMarker(toWriteVersion)
toDeployChaosVersion = formatter.AddDirtyMarker(toDeployChaosVersion)
}
recipeName, exists := app.Env["RECIPE"]
if !exists {
recipeName = app.Env["TYPE"]
}
envVersion, err := recipe.GetEnvVersionRaw(recipeName)
if err != nil {
return err
}
if envVersion == "" {
envVersion = config.NO_VERSION_DEFAULT
}
rows := [][]string{
@ -156,16 +170,16 @@ func DeployOverview(
{"CONFIG", deployConfig},
{"CURRENT DEPLOYMENT", "---"},
{"VERSION", deployedVersion},
{"CHAOS", deployedChaosVersion},
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
{"CHAOS", formatter.BoldDirtyDefault(deployedChaosVersion)},
{"NEW DEPLOYMENT", "---"},
{"VERSION", toDeployVersion},
{"CHAOS", toDeployChaosVersion},
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
{"CHAOS", formatter.BoldDirtyDefault(toDeployChaosVersion)},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
{"CURRENT VERSION", app.Recipe.EnvVersion},
{"NEW VERSION", toWriteVersion},
{"CURRENT VERSION", formatter.BoldDirtyDefault(envVersion)},
{"NEW VERSION", formatter.BoldDirtyDefault(toWriteVersion)},
}
overview := formatter.CreateOverview("DEPLOY OVERVIEW", rows)
@ -213,10 +227,6 @@ func UndeployOverview(
domain = config.NO_DOMAIN_DEFAULT
}
if app.Recipe.Dirty {
chaosVersion = formatter.BoldDirtyDefault(chaosVersion)
}
rows := [][]string{
{"APP", domain},
{"RECIPE", app.Recipe.Name},
@ -224,12 +234,12 @@ func UndeployOverview(
{"CONFIG", deployConfig},
{"CURRENT DEPLOYMENT", "---"},
{"DEPLOYED", version},
{"CHAOS", chaosVersion},
{"VERSION", formatter.BoldDirtyDefault(version)},
{"CHAOS", formatter.BoldDirtyDefault(chaosVersion)},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
{"CURRENT VERSION", app.Recipe.EnvVersion},
{"NEW VERSION", version},
{"CURRENT VERSION", formatter.BoldDirtyDefault(app.Recipe.EnvVersion)},
{"NEW VERSION", formatter.BoldDirtyDefault(version)},
}
overview := formatter.CreateOverview("UNDEPLOY OVERVIEW", rows)