fix: better message for redeploying chaos version
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

See #668
This commit is contained in:
2025-09-29 19:45:59 +02:00
parent a577ff3284
commit 7f4d14ea72
2 changed files with 8 additions and 3 deletions

View File

@ -104,7 +104,7 @@ checkout as-is. Recipe commit hashes are also supported as values for
toDeployVersion, err = getDeployVersion(args, deployMeta, app)
if err != nil {
log.Fatal(i18n.G("get deploy version: %s", err))
log.Fatal(err)
}
if !internal.Chaos {
@ -348,7 +348,12 @@ func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app appPkg.
// Check if the recipe has a version in the .env file
if app.Recipe.EnvVersion != "" && !internal.DeployLatest {
if strings.HasSuffix(app.Recipe.EnvVersionRaw, "+U") {
return "", errors.New(i18n.G("version: can not redeploy chaos version %s", app.Recipe.EnvVersionRaw))
// NOTE(d1): use double-line 5 spaces ("FATA ") trick to make a more
// informative error message. it's ugly but that's our logging situation
// atm
return "", errors.New(i18n.G(`cannot redeploy previous chaos version (%s), did you mean to use "--chaos"?
to return to a regular release, specify a release tag, commit SHA or use "--latest"`,
formatter.BoldDirtyDefault(app.Recipe.EnvVersionRaw)))
}
log.Debug(i18n.G("version: taking version from .env file: %s", app.Recipe.EnvVersion))
return app.Recipe.EnvVersion, nil

View File

@ -49,7 +49,7 @@ func (r Recipe) Ensure(ctx EnsureContext) error {
if r.EnvVersion != "" && !ctx.IgnoreEnvVersion {
log.Debug(i18n.G("ensuring env version %s", r.EnvVersion))
if strings.Contains(r.EnvVersion, "+U") {
return errors.New(i18n.G("can not redeploy chaos version (%s) without --chaos", r.EnvVersion))
return errors.New(i18n.G(`cannot redeploy previous chaos version (%s), did you mean to use "--chaos"?`))
}
if _, err := r.EnsureVersion(r.EnvVersion); err != nil {