remove profile dependency
This commit is contained in:
@@ -42,6 +42,26 @@ resolved() {
|
||||
}
|
||||
|
||||
|
||||
note "rig needs no profile"
|
||||
# rig assumes no configuration. A profile is an overlay on built-in defaults, so
|
||||
# a rig with no env.d/ at all must resolve, report, and still generate a kit —
|
||||
# and naming a profile that does not exist must still be an error, because a
|
||||
# typo that silently fell back to the defaults would be worse than a failure.
|
||||
NP="$(mktemp -d)"
|
||||
cp -r .. "$NP/rig"; rm -rf "$NP/rig/ctrl/env.d"; sed -i '/^PROFILE=/d' "$NP/rig/ctrl/.env" 2>/dev/null
|
||||
check "no env.d: config resolves" "default" \
|
||||
"$(cd "$NP/rig/ctrl" && bash -c 'source ./lib/config.sh; load_config >/dev/null && echo "$PROFILE_NAME"' 2>&1)"
|
||||
check "no env.d: the k8s version comes from the pins" "yes" \
|
||||
"$(cd "$NP/rig/ctrl" && bash -c 'source ./lib/config.sh; load_config >/dev/null && [ -n "$NODE_IMAGE" ] && echo yes' 2>&1)"
|
||||
check "no env.d: ports.sh active works" "7" \
|
||||
"$(cd "$NP/rig/ctrl" && bash ports.sh active 2>/dev/null | wc -w)"
|
||||
check "no env.d: a kit is generated for the defaults" "yes" \
|
||||
"$( (cd "$NP/rig/ctrl" && rm -rf ../standalone/*/ && bash standalone.sh write >/dev/null 2>&1) && [ -f "$NP/rig/standalone/default/rigdeps.sh" ] && echo yes || echo no)"
|
||||
check "a profile that does not exist is still an error" "yes" \
|
||||
"$( (cd "$NP/rig/ctrl" && PROFILE=no-such-profile bash -c 'source ./lib/config.sh; load_config' >/dev/null 2>&1) && echo no || echo yes)"
|
||||
rm -rf "$NP"
|
||||
|
||||
|
||||
note "the ports.sh active contract"
|
||||
# ports.sh active is read POSITIONALLY by two other files — the Makefile takes
|
||||
# $(word 2) and $(word 5), the Tiltfile takes _facts[0]..[6]. Insert a field in
|
||||
@@ -75,9 +95,11 @@ note "the caller's env beats the files"
|
||||
# get a real alternative rather than a sentinel.
|
||||
test_value() {
|
||||
case "$1" in
|
||||
PROFILE) echo "client" ;; # env.d/client.env exists
|
||||
K8S_VERSION) echo "v1_35" ;; # NODE_IMAGE_v1_35 is pinned
|
||||
KIND_CONFIG) echo "kind-config.client.yaml.tpl" ;; # the shape must exist
|
||||
# Picked from what exists, never named: rig must not need any particular
|
||||
# profile, template or pinned version to be present for this to run.
|
||||
PROFILE) config_profiles | head -1 ;;
|
||||
K8S_VERSION) (set -a; source ./versions.env; compgen -v NODE_IMAGE_v | sort -V | head -1 | sed 's/^NODE_IMAGE_//') ;;
|
||||
KIND_CONFIG) ls k8s/kind-config*.yaml.tpl 2>/dev/null | sort | head -1 | xargs -r basename ;;
|
||||
*_PORT) echo "19999" ;;
|
||||
CLUSTER) echo "selftest-name" ;;
|
||||
MANIFESTS_DIR) echo "../elsewhere/overlays/dev" ;;
|
||||
@@ -200,6 +222,30 @@ for mk in ../standalone/*/Makefile; do
|
||||
done
|
||||
check "there is a kit for every profile" "$(config_profiles | wc -l)" "$kits"
|
||||
|
||||
# An export is "take the setup I have here somewhere else", so it carries this
|
||||
# machine's CHOICES — profile, ports, manifest dir — and never its credentials:
|
||||
# ctrl/.env can hold registry and mirror logins next to those choices. The
|
||||
# committed per-profile kits carry neither, since they must be the same on any
|
||||
# machine. Proven with sentinel values in a scratch copy, because the real
|
||||
# ctrl/.env may have those keys empty — and an empty value proves nothing.
|
||||
SX="$TMP/export-proof"; mkdir -p "$SX"; cp -r .. "$SX/rig"
|
||||
cat >> "$SX/rig/ctrl/.env" <<'EOF'
|
||||
REGISTRY_USER=selftest-sentinel-user
|
||||
REGISTRY_PASSWORD=selftest-sentinel-password
|
||||
MANIFESTS_DIR=../selftest-sentinel-choice/overlays/dev
|
||||
EOF
|
||||
( cd "$SX/rig/ctrl" && bash standalone.sh export "$SX/out" >/dev/null 2>&1 )
|
||||
count_in() { grep -rcF -- "$1" "$2" 2>/dev/null | awk -F: '{s+=$2} END{print s+0}'; }
|
||||
check "export: carries this machine's choices" "yes" \
|
||||
"$([ "$(count_in selftest-sentinel-choice "$SX/out")" -gt 0 ] && echo yes || echo no)"
|
||||
check "export: carries no credential" "0" \
|
||||
"$(( $(count_in selftest-sentinel-user "$SX/out") + $(count_in selftest-sentinel-password "$SX/out") ))"
|
||||
check "per-profile kits: carry neither, whatever this machine has" "0" \
|
||||
"$( (cd "$SX/rig/ctrl" && source ./lib/config.sh && for p in $(config_profiles); do config_snapshot "$p"; done) \
|
||||
| grep -cE 'selftest-sentinel-(choice|user|password)')"
|
||||
check "export: refuses to write inside the repository" "yes" \
|
||||
"$( (bash standalone.sh export ../standalone/selftest-mine >/dev/null 2>&1) && echo no || echo yes)"
|
||||
|
||||
|
||||
note "optional — needs tilt and this rig's cluster"
|
||||
# Parsing the Tiltfile for real is the only way to know it still evaluates, but
|
||||
|
||||
Reference in New Issue
Block a user