From 06f5147f1fcf9de458ef7f4aff6a35959729c1d8 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 29 Sep 2025 18:48:58 +0200 Subject: [PATCH] refactor: chaos-y handling See https://git.coopcloud.tech/toolshed/abra/pulls/659 --- cli/app/deploy.go | 9 ++++----- tests/integration/app_deploy.bats | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cli/app/deploy.go b/cli/app/deploy.go index 17488a9c..5b36fc87 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -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) } diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 0d94a4a8..c1528c24 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -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