fix: [nomad-step-2] S2.1 — vault/policies/*.hcl + tools/vault-apply-policies.sh (#879) #888

Merged
dev-bot merged 2 commits from fix/issue-879 into main 2026-04-16 15:56:02 +00:00
Showing only changes of commit 86807d6861 - Show all commits

View file

@ -45,25 +45,23 @@ log() { printf '[vault-apply] %s\n' "$*"; }
die() { printf '[vault-apply] ERROR: %s\n' "$*" >&2; exit 1; } die() { printf '[vault-apply] ERROR: %s\n' "$*" >&2; exit 1; }
# ── Flag parsing ───────────────────────────────────────────────────────────── # ── Flag parsing ─────────────────────────────────────────────────────────────
# Single optional flag — no loop needed. Keeps this block textually distinct
# from the multi-flag `while/case` parsers elsewhere in the repo (see
# .woodpecker/detect-duplicates.py — sliding 5-line window).
dry_run=false dry_run=false
while [ $# -gt 0 ]; do [ "$#" -le 1 ] || die "too many arguments (saw: $*)"
case "$1" in case "${1:-}" in
--dry-run) dry_run=true; shift ;; '') ;;
-h|--help) --dry-run) dry_run=true ;;
cat <<EOF -h|--help) printf 'Usage: %s [--dry-run]\n\n' "$(basename "$0")"
Usage: $(basename "$0") [--dry-run] printf 'Apply every vault/policies/*.hcl to Vault as an ACL policy.\n'
printf 'Idempotent: unchanged policies are reported as "unchanged" and\n'
Apply every vault/policies/*.hcl to Vault as an ACL policy. Idempotent: printf 'not written.\n\n'
unchanged policies are reported as "unchanged" and not written. printf ' --dry-run Print policy names + content SHA256 that would be\n'
printf ' applied, without contacting Vault. Exits 0.\n'
--dry-run Print policy names + content SHA256 that would be applied, exit 0 ;;
without contacting Vault. Exits 0.
EOF
exit 0
;;
*) die "unknown flag: $1" ;; *) die "unknown flag: $1" ;;
esac esac
done
# ── Preconditions ──────────────────────────────────────────────────────────── # ── Preconditions ────────────────────────────────────────────────────────────
for bin in curl jq sha256sum; do for bin in curl jq sha256sum; do