forked from toolshed/abra
fix: more graceful bailing if borked .env.sample
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
msgid ""
|
||||
msgstr "Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2026-02-15 17:08+0100\n"
|
||||
"POT-Creation-Date: 2026-02-15 18:25+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -189,7 +189,7 @@ msgstr ""
|
||||
msgid "%d volumes removed successfully"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:191
|
||||
#: ./pkg/recipe/git.go:197
|
||||
#, c-format
|
||||
msgid "%s (%s) has locally unstaged changes?"
|
||||
msgstr ""
|
||||
@ -419,7 +419,7 @@ msgstr ""
|
||||
msgid "%s sanitised as %s for new app"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:439
|
||||
#: ./pkg/recipe/git.go:445
|
||||
#, c-format
|
||||
msgid "%s service is missing image tag?"
|
||||
msgstr ""
|
||||
@ -568,6 +568,11 @@ msgstr ""
|
||||
msgid "--local detected, running %s on local work station"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/lint/recipe.go:261 ./pkg/recipe/files.go:18
|
||||
#, c-format
|
||||
msgid ".env.sample for %s couldn't be read: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/lint/recipe.go:133
|
||||
msgid ".env.sample provided"
|
||||
msgstr ""
|
||||
@ -909,7 +914,7 @@ msgstr ""
|
||||
msgid "Generate the recipe catalogue"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:453
|
||||
#: ./pkg/recipe/git.go:459
|
||||
#, c-format
|
||||
msgid "GetRecipeVersions encountered error for %s: %s (collected %d versions)"
|
||||
msgstr ""
|
||||
@ -1827,7 +1832,7 @@ msgstr ""
|
||||
msgid "are you sure?"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:156
|
||||
#: ./pkg/recipe/git.go:162
|
||||
#, c-format
|
||||
msgid "attempting to checkout '%s' as chaos commit"
|
||||
msgstr ""
|
||||
@ -1958,7 +1963,7 @@ msgstr ""
|
||||
msgid "cancelled"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/catalogue/catalogue.go:59 ./pkg/recipe/git.go:245
|
||||
#: ./pkg/catalogue/catalogue.go:59 ./pkg/recipe/git.go:251
|
||||
#, c-format
|
||||
msgid "cannot ensure %s is up-to-date, no git remotes configured"
|
||||
msgstr ""
|
||||
@ -1978,7 +1983,7 @@ msgstr ""
|
||||
msgid "cannot parse %s, invalid tag specified?"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:52
|
||||
#: ./pkg/recipe/git.go:58
|
||||
#, c-format
|
||||
msgid "cannot redeploy previous chaos version (%s), did you mean to use \"--chaos\"?"
|
||||
msgstr ""
|
||||
@ -2121,7 +2126,7 @@ msgstr ""
|
||||
msgid "cmd"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:464
|
||||
#: ./pkg/recipe/git.go:470
|
||||
#, c-format
|
||||
msgid "collected %s for %s"
|
||||
msgstr ""
|
||||
@ -2298,7 +2303,7 @@ msgstr ""
|
||||
msgid "create remote directory: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/client/client.go:111
|
||||
#: ./pkg/client/client.go:109
|
||||
#, c-format
|
||||
msgid "created client for %s"
|
||||
msgstr ""
|
||||
@ -2443,7 +2448,7 @@ msgstr ""
|
||||
msgid "destination directory does not exist"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:367
|
||||
#: ./pkg/recipe/git.go:373
|
||||
#, c-format
|
||||
msgid "detected %s as tags for recipe %s"
|
||||
msgstr ""
|
||||
@ -2645,7 +2650,7 @@ msgstr ""
|
||||
msgid "ensure recipe: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:50
|
||||
#: ./pkg/recipe/git.go:56
|
||||
#, c-format
|
||||
msgid "ensuring env version %s"
|
||||
msgstr ""
|
||||
@ -2747,12 +2752,12 @@ msgstr ""
|
||||
msgid "failed to check git status of %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/git/branch.go:95 ./pkg/recipe/git.go:225
|
||||
#: ./pkg/git/branch.go:95 ./pkg/recipe/git.go:231
|
||||
#, c-format
|
||||
msgid "failed to check out %s in %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:406
|
||||
#: ./pkg/recipe/git.go:412
|
||||
#, c-format
|
||||
msgid "failed to check out %s in %s: %s"
|
||||
msgstr ""
|
||||
@ -2797,7 +2802,7 @@ msgstr ""
|
||||
msgid "failed to create volume %s on %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:415
|
||||
#: ./pkg/recipe/git.go:421
|
||||
#, c-format
|
||||
msgid "failed to get compose config for %s: %s"
|
||||
msgstr ""
|
||||
@ -2835,7 +2840,7 @@ msgstr ""
|
||||
msgid "failed to parse image %s, saw: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:425
|
||||
#: ./pkg/recipe/git.go:431
|
||||
#, c-format
|
||||
msgid "failed to parse image for %s in %s: %s"
|
||||
msgstr ""
|
||||
@ -2943,7 +2948,7 @@ msgstr ""
|
||||
msgid "fetch all recipes"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/catalogue/catalogue.go:84 ./pkg/recipe/git.go:278
|
||||
#: ./pkg/catalogue/catalogue.go:84 ./pkg/recipe/git.go:284
|
||||
#, c-format
|
||||
msgid "fetched latest git changes for %s"
|
||||
msgstr ""
|
||||
@ -3061,7 +3066,7 @@ msgstr ""
|
||||
msgid "git changes pushed"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:411
|
||||
#: ./pkg/recipe/git.go:417
|
||||
#, c-format
|
||||
msgid "git checkout: %s in %s"
|
||||
msgstr ""
|
||||
@ -3141,7 +3146,7 @@ msgstr ""
|
||||
msgid "git.coopcloud.tech repo exists"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:378
|
||||
#: ./pkg/recipe/git.go:384
|
||||
#, c-format
|
||||
msgid "git: opening repository in %s"
|
||||
msgstr ""
|
||||
@ -4054,7 +4059,7 @@ msgstr ""
|
||||
msgid "proceed?"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:398
|
||||
#: ./pkg/recipe/git.go:404
|
||||
#, c-format
|
||||
msgid "processing %s for %s"
|
||||
msgstr ""
|
||||
@ -4126,7 +4131,7 @@ msgstr ""
|
||||
msgid "re"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:151
|
||||
#: ./pkg/recipe/git.go:157
|
||||
#, c-format
|
||||
msgid "read %s as tags for recipe %s"
|
||||
msgstr ""
|
||||
@ -4683,17 +4688,17 @@ msgstr ""
|
||||
msgid "server doesn't exist?"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/client/client.go:54
|
||||
#: ./pkg/client/client.go:53
|
||||
#, c-format
|
||||
msgid "server missing context, context creation failed: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/client/client.go:59
|
||||
#: ./pkg/client/client.go:58
|
||||
#, c-format
|
||||
msgid "server missing context, run \"abra server add %s\"?"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/client/client.go:48
|
||||
#: ./pkg/client/client.go:47
|
||||
#, c-format
|
||||
msgid "server missing, run \"abra server add %s\"?"
|
||||
msgstr ""
|
||||
@ -4860,17 +4865,17 @@ msgstr ""
|
||||
msgid "skipping secret (because it already exists) on %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:407
|
||||
#: ./pkg/recipe/git.go:413
|
||||
#, c-format
|
||||
msgid "skipping tag %s: checkout failed: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:416
|
||||
#: ./pkg/recipe/git.go:422
|
||||
#, c-format
|
||||
msgid "skipping tag %s: invalid compose config: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:426
|
||||
#: ./pkg/recipe/git.go:432
|
||||
#, c-format
|
||||
msgid "skipping tag %s: invalid image reference in service %s: %s"
|
||||
msgstr ""
|
||||
@ -4973,7 +4978,7 @@ msgstr ""
|
||||
msgid "succeeded"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:178
|
||||
#: ./pkg/recipe/git.go:184
|
||||
#, c-format
|
||||
msgid "successfully checked %s out to %s in %s"
|
||||
msgstr ""
|
||||
@ -4988,12 +4993,12 @@ msgstr ""
|
||||
msgid "successfully created %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/client/client.go:120
|
||||
#: ./pkg/client/client.go:118
|
||||
#, c-format
|
||||
msgid "swarm mode not enabled on %s?"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/client/client.go:123
|
||||
#: ./pkg/client/client.go:121
|
||||
msgid "swarm mode not enabled on local server?"
|
||||
msgstr ""
|
||||
|
||||
@ -5138,12 +5143,12 @@ msgstr ""
|
||||
msgid "un"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:187
|
||||
#: ./pkg/recipe/git.go:193
|
||||
#, c-format
|
||||
msgid "unable to check git clean status in %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:256
|
||||
#: ./pkg/recipe/git.go:262
|
||||
#, c-format
|
||||
msgid "unable to check out default branch in %s: %s"
|
||||
msgstr ""
|
||||
@ -5212,17 +5217,12 @@ msgstr ""
|
||||
msgid "unable to determine versioning semantics of %s, listing all tags"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/lint/recipe.go:261 ./pkg/recipe/files.go:18
|
||||
#, c-format
|
||||
msgid "unable to discover .env.sample for %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./cli/recipe/fetch.go:71
|
||||
#, c-format
|
||||
msgid "unable to discover SSH remote for %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:262
|
||||
#: ./pkg/recipe/git.go:268
|
||||
#, c-format
|
||||
msgid "unable to fetch tags in %s: %s"
|
||||
msgstr ""
|
||||
@ -5232,7 +5232,7 @@ msgstr ""
|
||||
msgid "unable to get container matching %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:274
|
||||
#: ./pkg/recipe/git.go:280
|
||||
#, c-format
|
||||
msgid "unable to git pull in %s: %s"
|
||||
msgstr ""
|
||||
@ -5256,12 +5256,12 @@ msgstr ""
|
||||
msgid "unable to look up server context for %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./cli/recipe/fetch.go:77 ./pkg/git/read.go:26 ./pkg/lint/recipe.go:491 ./pkg/recipe/git.go:236
|
||||
#: ./cli/recipe/fetch.go:77 ./pkg/git/read.go:26 ./pkg/lint/recipe.go:491 ./pkg/recipe/git.go:242
|
||||
#, c-format
|
||||
msgid "unable to open %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:251
|
||||
#: ./pkg/recipe/git.go:257
|
||||
#, c-format
|
||||
msgid "unable to open git work tree in %s: %s"
|
||||
msgstr ""
|
||||
@ -5321,7 +5321,7 @@ msgstr ""
|
||||
msgid "unable to read new env %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:241
|
||||
#: ./pkg/recipe/git.go:247
|
||||
#, c-format
|
||||
msgid "unable to read remotes in %s: %s"
|
||||
msgstr ""
|
||||
@ -5356,7 +5356,7 @@ msgstr ""
|
||||
msgid "unable to render to JSON: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ./pkg/recipe/git.go:160
|
||||
#: ./pkg/recipe/git.go:166
|
||||
#, c-format
|
||||
msgid "unable to resolve '%s': %s"
|
||||
msgstr ""
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -258,7 +258,7 @@ func LintAppService(recipe recipe.Recipe) (bool, error) {
|
||||
func LintTraefikEnabledSkipCondition(r recipe.Recipe) (bool, error) {
|
||||
sampleEnv, err := r.SampleEnv()
|
||||
if err != nil {
|
||||
return false, errors.New(i18n.G("unable to discover .env.sample for %s", r.Name))
|
||||
return false, errors.New(i18n.G(".env.sample for %s couldn't be read: %s", r.Name, err))
|
||||
}
|
||||
|
||||
if _, ok := sampleEnv["DOMAIN"]; !ok {
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
func (r Recipe) SampleEnv() (map[string]string, error) {
|
||||
sampleEnv, err := envfile.ReadEnv(r.SampleEnvPath)
|
||||
if err != nil {
|
||||
return sampleEnv, errors.New(i18n.G("unable to discover .env.sample for %s", r.Name))
|
||||
return sampleEnv, errors.New(i18n.G(".env.sample for %s couldn't be read: %s", r.Name, err))
|
||||
}
|
||||
return sampleEnv, nil
|
||||
}
|
||||
|
||||
@ -32,6 +32,12 @@ func (r Recipe) Ensure(ctx EnsureContext) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// NOTE(d1): if we cannot parse the .env.sample then there is a
|
||||
// fundamental problem which requires solving right now
|
||||
if _, err := r.SampleEnv(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ctx.Chaos {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -30,6 +30,11 @@ teardown(){
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
|
||||
if [[ -d "$ABRA_DIR/recipes/foo" ]]; then
|
||||
run rm -rf "$ABRA_DIR/recipes/foo"
|
||||
assert_not_exists "$ABRA_DIR/recipes/foo"
|
||||
fi
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
@ -610,8 +615,6 @@ teardown(){
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_success
|
||||
|
||||
# run sed -i 's/#COMPOSE_FILE="$COMPOSE_FILE:compose.udp-and-tcp.yml"/COMPOSE_FILE="$COMPOSE_FILE:compose.udp-and-tcp.yml"/g' \
|
||||
# "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
run bash -c "printf '\nCOMPOSE_FILE=\"\$COMPOSE_FILE:compose.udp-and-tcp.yml\"' >> $ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_success
|
||||
|
||||
@ -669,3 +672,25 @@ teardown(){
|
||||
assert_failure
|
||||
assert_output --partial "unable to parse"
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "app deploy with borked sample env gives useful error" {
|
||||
run $ABRA recipe new foo --no-input
|
||||
assert_success
|
||||
|
||||
run $ABRA app new foo \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "foo.$TEST_SERVER" \
|
||||
--chaos
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/foo.$TEST_SERVER.env"
|
||||
|
||||
run bash -c "printf '\nEVIL-VAR=EVIL' >> $ABRA_DIR/recipes/foo/.env.sample"
|
||||
assert_success
|
||||
|
||||
run $ABRA app deploy "foo.$TEST_SERVER" \
|
||||
--no-input --no-converge-checks --chaos
|
||||
assert_failure
|
||||
assert_output --partial "unexpected character"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user