Consolidate all the Helm Makefiles (#65455)

* Extract Helm logic into lib

* Add helm-janitor

* Fix lint values

* Use helmjanitor for tests, lint, and version-update

* Convert example/chart Makefile to helm-janitor + add library support

* Fix release pipeline

* lint

* Disable CGO

* lint
This commit is contained in:
Hugo Shaka
2026-04-29 21:26:31 +00:00
committed by GitHub
parent 7bb55db115
commit 8ea6a9b687
36 changed files with 1216 additions and 393 deletions
+12 -40
View File
@@ -288,6 +288,14 @@ VERSRC = gitref.go api/version.go
KUBECONFIG ?=
TEST_KUBE ?=
# This unexport statement is required for make to work with the `-e` flag.
# With -e, the first Makefile sets HELMJANITOR=$$(go tool ...),
# passes HELMJANITOR=$(go tool) to the child make process.
# Because of the `-e` flag it takes precedence over the child's make definition
# of HELMJANITOR and breaks environment variable expansion.
# To avoid breaking other parts of the release pipeline, the easiest fix is to
# unexport HELMJANITOR so the child uses the definition from its Makefile.
unexport HELMJANITOR
export KUBECONFIG
export TEST_KUBE
@@ -950,25 +958,11 @@ helmunit/installed:
# environment variable.
.PHONY: test-helm
test-helm: helmunit/installed
helm unittest -3 --with-subchart=false examples/chart/teleport-cluster
helm unittest -3 --with-subchart=false examples/chart/teleport-kube-agent
helm unittest -3 --with-subchart=false examples/chart/teleport-relay
helm unittest -3 --with-subchart=false examples/chart/teleport-cluster/charts/teleport-operator
helm unittest -3 --with-subchart=false examples/chart/access/*
helm unittest -3 --with-subchart=false examples/chart/event-handler
helm unittest -3 --with-subchart=false examples/chart/tbot
helm unittest -3 --with-subchart=false examples/chart/tbot-spiffe-daemon-set
$(HELMJANITOR) test
.PHONY: test-helm-update-snapshots
test-helm-update-snapshots: helmunit/installed
helm unittest -3 -u --with-subchart=false examples/chart/teleport-cluster
helm unittest -3 -u --with-subchart=false examples/chart/teleport-kube-agent
helm unittest -3 -u --with-subchart=false examples/chart/teleport-relay
helm unittest -3 -u --with-subchart=false examples/chart/teleport-cluster/charts/teleport-operator
helm unittest -3 -u --with-subchart=false examples/chart/access/*
helm unittest -3 -u --with-subchart=false examples/chart/event-handler
helm unittest -3 -u --with-subchart=false examples/chart/tbot
helm unittest -3 -u --with-subchart=false examples/chart/tbot-spiffe-daemon-set
$(HELMJANITOR) test --update-snapshots
#
# Runs all Go tests except integration, called by CI/CD.
@@ -1382,30 +1376,8 @@ lint-sh:
# If errors are found, the file is printed with line numbers to aid in debugging.
.PHONY: lint-helm
lint-helm:
@if ! type yamllint 2>&1 >/dev/null; then \
echo "Not running 'lint-helm' target as 'yamllint' is not installed."; \
if [ "$${CI}" = "true" ]; then echo "This is a failure when running in CI." && exit 1; fi; \
exit 0; \
fi; \
for CHART in ./examples/chart/teleport-cluster ./examples/chart/teleport-kube-agent ./examples/chart/teleport-relay ./examples/chart/teleport-cluster/charts/teleport-operator ./examples/chart/tbot ./examples/chart/tbot-spiffe-daemon-set; do \
if [ -d $${CHART}/.lint ]; then \
for VALUES in $${CHART}/.lint/*.yaml; do \
export HELM_TEMP=$$(mktemp); \
echo -n "Using values from '$${VALUES}': "; \
yamllint -c examples/chart/.lint-config.yaml $${VALUES} || { cat -en $${VALUES}; exit 1; }; \
helm lint --quiet --strict $${CHART} -f $${VALUES} || exit 1; \
helm template test $${CHART} -f $${VALUES} 1>$${HELM_TEMP} || exit 1; \
yamllint -c examples/chart/.lint-config.yaml $${HELM_TEMP} || { cat -en $${HELM_TEMP}; exit 1; }; \
echo; \
done \
else \
export HELM_TEMP=$$(mktemp); \
helm lint --quiet --strict $${CHART} || exit 1; \
helm template test $${CHART} 1>$${HELM_TEMP} || exit 1; \
yamllint -c examples/chart/.lint-config.yaml $${HELM_TEMP} || { cat -en $${HELM_TEMP}; exit 1; }; \
fi; \
done
$(MAKE) -C examples/chart check-chart-ref
$(HELMJANITOR) reference -check
$(HELMJANITOR) lint
ADDLICENSE_COMMON_ARGS := -c 'Gravitational, Inc.' \
-ignore '**/*.c' \