install: fix peer template resolution in self-update path

This commit is contained in:
Brad Stein 2026-04-09 11:46:15 -03:00
parent 9732272d17
commit eb28ada6e2
3 changed files with 68 additions and 18 deletions

View File

@ -700,18 +700,22 @@ resolve_build_target() {
install_config_template() { install_config_template() {
local template="$1" local template="$1"
local dest="$2" local dest="$2"
local src modern legacy local src legacy
local -a modern_candidates=()
local -a legacy_candidates=()
modern="configs/ananke.${template}.yaml"
case "${template}" in case "${template}" in
coordinator) coordinator)
legacy="configs/hecate.titan-db.yaml" modern_candidates=("configs/ananke.coordinator.yaml" "configs/ananke.titan-db.yaml")
legacy_candidates=("configs/hecate.titan-db.yaml")
;; ;;
peer) peer)
legacy="configs/hecate.tethys.yaml" modern_candidates=("configs/ananke.peer.yaml" "configs/ananke.tethys.yaml")
legacy_candidates=("configs/hecate.tethys.yaml")
;; ;;
example) example)
legacy="configs/hecate.example.yaml" modern_candidates=("configs/ananke.example.yaml")
legacy_candidates=("configs/hecate.example.yaml")
;; ;;
*) *)
echo "[install] unknown config template key: ${template}" >&2 echo "[install] unknown config template key: ${template}" >&2
@ -719,21 +723,24 @@ install_config_template() {
;; ;;
esac esac
if [[ -f "${modern}" ]]; then for src in "${modern_candidates[@]}"; do
src="${modern}" if [[ -f "${src}" ]]; then
install -m 0640 "${src}" "${dest}" install -m 0640 "${src}" "${dest}"
return 0 return 0
fi fi
done
if [[ -f "${legacy}" ]]; then for legacy in "${legacy_candidates[@]}"; do
src="$(mktemp)" if [[ -f "${legacy}" ]]; then
legacy_path_rewrite "${legacy}" "${src}" src="$(mktemp)"
install -m 0640 "${src}" "${dest}" legacy_path_rewrite "${legacy}" "${src}"
rm -f "${src}" install -m 0640 "${src}" "${dest}"
return 0 rm -f "${src}"
fi return 0
fi
done
echo "[install] missing both modern and legacy config templates for '${template}'." >&2 echo "[install] missing config template sources for '${template}'. modern=[${modern_candidates[*]}] legacy=[${legacy_candidates[*]}]" >&2
return 1 return 1
} }

View File

@ -105,6 +105,9 @@ cd "${REPO_DIR}"
echo "[quality] lint" echo "[quality] lint"
./scripts/lint.sh ./scripts/lint.sh
echo "[quality] installer template contracts"
./scripts/verify_install_templates.sh
echo "[quality] per-file coverage gate (95%)" echo "[quality] per-file coverage gate (95%)"
cd testing cd testing
ANANKE_ENFORCE_COVERAGE=1 ANANKE_PER_FILE_COVERAGE_TARGET=95 go test ./coverage -run TestPerFileCoverageReport -count=1 -v ANANKE_ENFORCE_COVERAGE=1 ANANKE_PER_FILE_COVERAGE_TARGET=95 go test ./coverage -run TestPerFileCoverageReport -count=1 -v

View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_DIR}"
check_template() {
local template="$1"
shift
local found=""
local candidate
for candidate in "$@"; do
if [[ -f "${candidate}" ]]; then
found="${candidate}"
break
fi
done
if [[ -z "${found}" ]]; then
echo "[template-contract] ${template}: no candidate exists: $*" >&2
return 1
fi
echo "[template-contract] ${template}: ${found}"
return 0
}
check_template coordinator \
"configs/ananke.coordinator.yaml" \
"configs/ananke.titan-db.yaml" \
"configs/hecate.titan-db.yaml"
check_template peer \
"configs/ananke.peer.yaml" \
"configs/ananke.tethys.yaml" \
"configs/hecate.tethys.yaml"
check_template example \
"configs/ananke.example.yaml" \
"configs/hecate.example.yaml"