Files
jcoffey-dev 81b6fa4854 Docs pages generated from the chart: values, ports and policies, alerts (K-D2)
tools/docs-pages.py writes the generated pages of the docs' Kubernetes
section into a folder (the docs repo's content/docs/kubernetes), the way
inbuxa-admin's build-manual.mjs writes the settings reference:

- values.md: every value, from values.yaml and the schema (the same
  entries as VALUES.md; values-reference.py now exposes them as body()).
- ports.md: each Service, its type, the Deployments it sends to and its
  ports, and what each NetworkPolicy lets in and out.
- alerts.md: each alert rule, its severity, its wait, when it fires and
  what to do, with Prometheus' templating turned into words.

Rendered with ci/docs-values.yaml: the defaults with webmail, console,
metrics and backups on, so every part shows. check.sh builds them (CI
gets python3-yaml for that); ci/ also puts the file through every other
check.
2026-11-19 14:21:04 -07:00

92 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
# SPDX-License-Identifier: Apache-2.0
#
# Every check CI runs on the chart, in the order it runs them. Run it before
# you push: tools/install-tools.sh puts the pinned tools in .tools/bin, and
# this script uses them from there when they're present.
#
# tools/install-tools.sh && tools/check.sh
set -euo pipefail
cd "$(dirname "$0")/.."
[ -d .tools/bin ] && PATH="$PWD/.tools/bin:$PATH"
CHART=charts/inbuxa
# The three newest Kubernetes minors (support matrix). kubeconform's schema
# set has to have them: a new minor is added here once it does.
KUBE_VERSIONS=(1.35.0 1.36.0 1.37.0)
OUT="$(mktemp -d)"
trap 'rm -rf "$OUT"' EXIT
step() { printf '\n== %s\n' "$*"; }
for helm in helm helm3; do
step "$helm lint ($($helm version --short))"
for values in "$CHART"/ci/*-values.yaml; do
$helm lint --strict "$CHART" -f "$values"
done
done
step "the values reference is current (tools/values-reference.py)"
python3 tools/values-reference.py --check
step "the docs' generated Kubernetes pages build (tools/docs-pages.py)"
python3 tools/docs-pages.py --out "$OUT/docs"
step "bad values are refused before anything is applied (tools/bad-values)"
# Each file's first line names what the refusal has to mention. helm
# template, as an install renders: the schema and the templates' own checks.
for bad in tools/bad-values/*.yaml; do
want=$(sed -n '1s/^# refuses: //p' "$bad")
[ -n "$want" ] || { echo "!! $bad: no '# refuses:' line" >&2; exit 1; }
if helm template t "$CHART" -f "$CHART/ci/defaults-values.yaml" -f "$bad" >"$OUT/bad.log" 2>&1; then
echo "!! accepted: $bad" >&2
exit 1
fi
grep -Eq "$want" "$OUT/bad.log" || {
echo "!! $bad refused, but not for /$want/:" >&2
cat "$OUT/bad.log" >&2
exit 1
}
echo "refused: $(basename "$bad" .yaml)"
done
step "the values schema rejects a key it doesn't know"
if helm lint --strict "$CHART" -f "$CHART/ci/defaults-values.yaml" --set notAValue=1 >"$OUT/reject.log" 2>&1; then
echo "!! an unknown value was accepted" >&2
exit 1
fi
grep -q "notAValue" "$OUT/reject.log" || {
echo "!! refused, but not over the unknown value:" >&2
cat "$OUT/reject.log" >&2
exit 1
}
echo "refused, as it should be"
for values in "$CHART"/ci/*-values.yaml; do
name="$(basename "$values" -values.yaml)"
for kube in "${KUBE_VERSIONS[@]}"; do
step "kubeconform: $name values on Kubernetes $kube"
helm template ci "$CHART" -n inbuxa -f "$values" --kube-version "$kube" >"$OUT/$name-$kube.yaml"
# HTTPRoute is a CRD: its schema comes from the CRDs catalog
kubeconform -strict -summary -kubernetes-version "$kube" \
-schema-location default \
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
"$OUT/$name-$kube.yaml"
done
step "kube-linter: $name values"
rendered="$OUT/$name-${KUBE_VERSIONS[-1]}.yaml"
if grep -q '^kind:' "$rendered"; then
kube-linter lint --config .kube-linter.yaml "$rendered"
else
# kube-linter treats "no objects" as a failure
echo "nothing rendered, nothing to lint"
fi
done
step "helm-unittest"
helm-unittest --strict "$CHART"
printf '\nAll checks passed.\n'