infra: fly-shadow-run check reads fly.env as KEY=VALUE lines, never sources it
fly.env is systemd EnvironmentFile syntax; GAME_TITLE=Pokemon Red is valid there and a shell error when sourced. The v0.7.3 cutover's check died on it (exit 127) after a passing verdict. Parse it as fly-runtime does; lint refuses any infra/bin script that sources fly.env.
This commit is contained in:
parent
16cb3b754b
commit
390d118460
2 changed files with 24 additions and 5 deletions
|
|
@ -549,11 +549,20 @@ PY
|
|||
exit 1
|
||||
fi
|
||||
[ -x "$BIN" ] || die "$BIN is missing"
|
||||
# The live service's configuration, for its compatibility string.
|
||||
set -a
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
. "${FLY_ENV_FILE:-/etc/fly/fly.env}"
|
||||
set +a
|
||||
# The live service's configuration, for its compatibility string. fly.env is systemd's
|
||||
# EnvironmentFile syntax (GAME_TITLE=Pokemon Red is valid there), so it is read as KEY=VALUE
|
||||
# lines, as fly-runtime does, never sourced as shell.
|
||||
local line key value env_file="${FLY_ENV_FILE:-/etc/fly/fly.env}"
|
||||
if [ -f "$env_file" ]; then
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
[[ "$line" =~ ^[A-Za-z_][A-Za-z0-9_]*= ]] || continue
|
||||
key="${line%%=*}"
|
||||
value="${line#*=}"
|
||||
value="${value%\"}"
|
||||
value="${value#\"}"
|
||||
export "${key}=${value}"
|
||||
done <"$env_file"
|
||||
fi
|
||||
# The release CUT-01 switches into and the binary it switches to: SERVE-01's service there.
|
||||
"$BIN" check --verdict "$SHADOW_DIR/verdict.json" --current "${FLY_CURRENT_DIR:-/opt/fly/current}" \
|
||||
--binary flysim-session "$@"
|
||||
|
|
|
|||
|
|
@ -2355,6 +2355,16 @@ else
|
|||
fail "loop recovery tests failed; run python3 -m unittest discover -s infra/tests -p test_loop_recover.py -v"
|
||||
fi
|
||||
|
||||
echo "--- fly.env is read, never sourced ---"
|
||||
# fly.env is systemd EnvironmentFile syntax: GAME_TITLE=Pokemon Red is valid there and a shell
|
||||
# error when sourced (the v0.7.3 cutover's check died on it). Scripts parse KEY=VALUE lines.
|
||||
sourced="$(grep -n -E '^[[:space:]]*(\.|source)[[:space:]]+.*(fly\.env|FLY_ENV_FILE)' "$REPO_ROOT"/infra/bin/* 2>/dev/null || true)"
|
||||
if [ -z "$sourced" ]; then
|
||||
pass "no infra/bin script sources fly.env"
|
||||
else
|
||||
fail "fly.env sourced as shell (parse KEY=VALUE lines instead): $sourced"
|
||||
fi
|
||||
|
||||
echo "==="
|
||||
if [ "$FAILED" -eq 0 ]; then
|
||||
echo "lint.sh: ALL CHECKS PASSED"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue