refactor: chaos-y handling

See #659
This commit is contained in:
2025-09-29 18:48:58 +02:00
parent 3696d63a34
commit 06f5147f1f
2 changed files with 5 additions and 6 deletions

View File

@ -107,15 +107,14 @@ checkout as-is. Recipe commit hashes are also supported as values for
log.Fatal(i18n.G("get deploy version: %s", err))
}
versionIsChaos := false
if !internal.Chaos {
var err error
versionIsChaos, err = app.Recipe.EnsureVersion(toDeployVersion)
isChaosCommit, err := app.Recipe.EnsureVersion(toDeployVersion)
if err != nil {
log.Fatal(i18n.G("ensure recipe: %s", err))
}
if versionIsChaos {
if isChaosCommit {
log.Warnf(i18n.G("version '%s' appears to be a chaos commit, but --chaos/-C was not provided", toDeployVersion))
internal.Chaos = true
}
}
@ -155,7 +154,7 @@ checkout as-is. Recipe commit hashes are also supported as values for
appPkg.ExposeAllEnv(stackName, compose, app.Env)
appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
appPkg.SetChaosLabel(compose, stackName, internal.Chaos || versionIsChaos)
appPkg.SetChaosLabel(compose, stackName, internal.Chaos)
if internal.Chaos {
appPkg.SetChaosVersionLabel(compose, stackName, toDeployVersion)
}

View File

@ -175,7 +175,7 @@ teardown(){
}
# bats test_tags=slow
@test "bail if env has a hash but no --chaos" {
@test "do not bail if env version is a hash but no --chaos" {
wantHash=$(_get_n_hash 3)
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3