Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ssm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SSM_ENV ?=
# Service segment of the parameter path. Defaults to the repo name (git remote
# basename, else the working-directory name) so every repo that inherits these
# helpers targets its own path without configuration.
SSM_REPO_NAME = $(shell git config --get remote.origin.url 2>/dev/null | sed -E 's#.*/##; s#\.git$$##')
SSM_REPO_NAME = $(shell git config --get remote.origin.url 2>/dev/null | sed -E 's,.*/,,; s,\.git$$,,')
SSM_SERVICE ?= $(if $(SSM_REPO_NAME),$(SSM_REPO_NAME),$(notdir $(CURDIR)))

# Parameter path convention from RFC #356.1: /ecs/<env>/<service>/<KEY>.
Expand Down
15 changes: 15 additions & 0 deletions test/ssm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ echo "ssm_guard_production recipe:"; printf '%s\n' "$guard" | sed 's/^/ | /'; e
expect "ssm_guard derives env from the stem" "ENV='production'" "$guard"
expect "ssm_guard runs the guard program" 'sh -eu -c "$SSM_GUARD"' "$guard"

# --- 1b. derived-service render guard (regression) -----------------------------
# When a consumer does NOT set SSM_SERVICE (the common case), it is derived via
# $(shell ...) in SSM_REPO_NAME — and a malformed shell call there (e.g. a `#`
# inside it, which GNU Make 3.81 mis-tokenises) aborts with "unterminated call to
# function". The rest of this file always pins SSM_SERVICE, which short-circuits
# that expansion, so render once WITHOUT it to exercise the derivation path.
incdir=$(mktemp -d -t ssm_inc.XXXXXX)
cp "$repo_root/ssm.mk" "$incdir/ssm.mk"
printf -- '-include %s/ssm.mk\n' "$incdir" > "$incdir/Makefile"
inc=$(make -C "$incdir" -n ssm_guard_test AWS_REGION=eu-west-1 2>&1 || true)
rm -rf "$incdir"
echo
refute "SSM_REPO_NAME shell call is well-formed" "unterminated call to function" "$inc"
expect "renders with a derived service prefix" "/ecs/test/" "$inc"

# --- 2. the exported shell programs --------------------------------------------

helper=$(mktemp -t ssm_helper.XXXXXX)
Expand Down
Loading