fix: fix: vault_request RETURN trap fires prematurely when vault-env.sh is sourced (#773)
This commit is contained in:
parent
c77fb1dc53
commit
96870d9f30
1 changed files with 5 additions and 1 deletions
|
|
@ -128,7 +128,6 @@ vault_request() {
|
||||||
# Validate TOML content
|
# Validate TOML content
|
||||||
local tmp_toml
|
local tmp_toml
|
||||||
tmp_toml=$(mktemp /tmp/vault-XXXXXX.toml)
|
tmp_toml=$(mktemp /tmp/vault-XXXXXX.toml)
|
||||||
trap 'rm -f "$tmp_toml"' RETURN
|
|
||||||
|
|
||||||
printf '%s' "$toml_content" > "$tmp_toml"
|
printf '%s' "$toml_content" > "$tmp_toml"
|
||||||
|
|
||||||
|
|
@ -136,6 +135,7 @@ vault_request() {
|
||||||
local vault_env="${FACTORY_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}/action-vault/vault-env.sh"
|
local vault_env="${FACTORY_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}/action-vault/vault-env.sh"
|
||||||
if [ ! -f "$vault_env" ]; then
|
if [ ! -f "$vault_env" ]; then
|
||||||
echo "ERROR: vault-env.sh not found at $vault_env" >&2
|
echo "ERROR: vault-env.sh not found at $vault_env" >&2
|
||||||
|
rm -f "$tmp_toml"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -145,11 +145,15 @@ vault_request() {
|
||||||
if ! source "$vault_env"; then
|
if ! source "$vault_env"; then
|
||||||
FORGE_TOKEN="${_saved_forge_token:-}"
|
FORGE_TOKEN="${_saved_forge_token:-}"
|
||||||
echo "ERROR: failed to source vault-env.sh" >&2
|
echo "ERROR: failed to source vault-env.sh" >&2
|
||||||
|
rm -f "$tmp_toml"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Restore caller's FORGE_TOKEN after validation
|
# Restore caller's FORGE_TOKEN after validation
|
||||||
FORGE_TOKEN="${_saved_forge_token:-}"
|
FORGE_TOKEN="${_saved_forge_token:-}"
|
||||||
|
|
||||||
|
# Set trap AFTER sourcing vault-env.sh to avoid RETURN trap firing during source
|
||||||
|
trap 'rm -f "$tmp_toml"' RETURN
|
||||||
|
|
||||||
# Run validation
|
# Run validation
|
||||||
if ! validate_vault_action "$tmp_toml"; then
|
if ! validate_vault_action "$tmp_toml"; then
|
||||||
echo "ERROR: TOML validation failed" >&2
|
echo "ERROR: TOML validation failed" >&2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue