mirror of
https://github.com/hanzoai/cd.git
synced 2026-10-30 14:56:45 +00:00
charts/cd installs the same hanzocd-* objects manifests/install.yaml does (59/59 identical by kind+name) so `helm install` is a first-class path alongside kubectl -k. HA mode (ha.enabled) swaps in the redis-ha dependency, matching manifests/ha/install.yaml outside the redis subsystem (53/53 identical); hack/verify-helm-chart.sh enforces both on every run and is wired into `make release-precheck`. Fixes discovered getting there: the four HA kustomize overlays and the redis-ha proxy NetworkPolicy still targeted pre-rename cd-* names, so `kustomize build manifests/ha/cluster-install` was broken and the committed manifests/ha/*.yaml were stale (still shipping cd-server et al). Regenerated all four ha/*.yaml from the fixed base. The Helm chart also closes a second gap: nothing created the hanzocd-redis secret for HA installs (the vendored redis-ha chart's own pods never run our redis-initial-password bootstrap), so charts/cd runs it once as a pre-install hook.
83 lines
3.1 KiB
Bash
Executable File
83 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Fails the moment charts/cd stops agreeing with the kustomize manifests it
|
|
# was derived from. Run after changing either manifests/base/** or
|
|
# charts/cd/templates/**.
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
SRCROOT="$(CDPATH='' cd -- "$(dirname "$0")/.." && pwd -P)"
|
|
CHART="${SRCROOT}/charts/cd"
|
|
WORK="$(mktemp -d)"
|
|
trap 'rm -rf "${WORK}"' EXIT
|
|
|
|
for bin in helm kustomize kubectl python3; do
|
|
if ! command -v "$bin" >/dev/null 2>&1; then
|
|
echo "verify-helm-chart: '$bin' is not installed, cannot verify" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
kind_name() {
|
|
python3 - "$1" <<'PY'
|
|
import sys, yaml
|
|
with open(sys.argv[1]) as f:
|
|
docs = yaml.safe_load_all(f)
|
|
out = []
|
|
for d in docs:
|
|
if not d:
|
|
continue
|
|
kind = d.get("kind", "")
|
|
name = (d.get("metadata") or {}).get("name", "")
|
|
out.append(f"{kind}\t{name}")
|
|
for line in sorted(out):
|
|
print(line)
|
|
PY
|
|
}
|
|
|
|
echo "==> helm dependency update"
|
|
helm dependency update "${CHART}" >/dev/null
|
|
|
|
echo "==> helm lint (default values)"
|
|
helm lint "${CHART}"
|
|
|
|
echo "==> helm lint (ha, hydrator, ingress, namespace-scoped)"
|
|
helm lint "${CHART}" \
|
|
--set ha.enabled=true \
|
|
--set hydrator.enabled=true \
|
|
--set server.ingress.enabled=true \
|
|
--set global.clusterScope=false
|
|
|
|
echo "==> helm template (default) vs manifests/install.yaml"
|
|
helm template hanzocd "${CHART}" --namespace cd --include-crds >"${WORK}/helm-default.yaml"
|
|
kind_name "${WORK}/helm-default.yaml" >"${WORK}/helm-default.kn"
|
|
kind_name "${SRCROOT}/manifests/install.yaml" >"${WORK}/kustomize-default.kn"
|
|
if ! diff -u "${WORK}/kustomize-default.kn" "${WORK}/helm-default.kn"; then
|
|
echo "verify-helm-chart: default render does not match manifests/install.yaml" >&2
|
|
exit 1
|
|
fi
|
|
echo " identical ($(wc -l <"${WORK}/kustomize-default.kn" | tr -d ' ') objects)"
|
|
|
|
echo "==> kubectl apply --dry-run=client (default)"
|
|
kubectl apply --dry-run=client -f "${WORK}/helm-default.yaml" >/dev/null
|
|
|
|
echo "==> helm template (ha.enabled=true) vs manifests/ha/install.yaml, redis subsystem excluded"
|
|
# ha.enabled swaps the single redis Deployment for the redis-ha dependency
|
|
# (github.com/DandyDeveloper/charts), fullnameOverride'd to hanzocd-redis-ha;
|
|
# object names there differ from the kustomize-vendored cd-redis-ha-* by
|
|
# design (see charts/cd/README.md), and its Helm test-hook Pods only run on
|
|
# `helm test`, never on install/upgrade. Everything else must match exactly.
|
|
helm template hanzocd "${CHART}" --namespace cd --include-crds --set ha.enabled=true >"${WORK}/helm-ha.yaml"
|
|
kind_name "${WORK}/helm-ha.yaml" | grep -vi redis | grep -v '^Pod\b' >"${WORK}/helm-ha.kn"
|
|
kind_name "${SRCROOT}/manifests/ha/install.yaml" | grep -vi redis >"${WORK}/kustomize-ha.kn"
|
|
if ! diff -u "${WORK}/kustomize-ha.kn" "${WORK}/helm-ha.kn"; then
|
|
echo "verify-helm-chart: ha render does not match manifests/ha/install.yaml outside the redis subsystem" >&2
|
|
exit 1
|
|
fi
|
|
echo " identical ($(wc -l <"${WORK}/kustomize-ha.kn" | tr -d ' ') non-redis objects)"
|
|
|
|
echo "==> kubectl apply --dry-run=client (ha)"
|
|
kubectl apply --dry-run=client -f "${WORK}/helm-ha.yaml" >/dev/null
|
|
|
|
echo "verify-helm-chart: OK"
|