Repository navigation
Expand file tree
/
Copy pathMakefile.custom.mk
More file actions
66 lines (58 loc) · 3.16 KB
/
Copy pathMakefile.custom.mk
File metadata and controls
66 lines (58 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# The chart the generated Makefile.gen.app.mk targets act on. `make helm-docs`
# regenerates helm/agent/README.md with the flags CI's pre-commit hook uses
# (--sort-values-order=file); a bare `helm-docs` sorts alphanumerically and
# reorders the values table.
APPLICATION := agent
##@ Helm
# Repo-owned targets next to the generated Makefile.gen.app.mk. `make help`
# lists them. The chart-test CircleCI job (.circleci/custom.yml) runs
# `make helm-test`; the ATS smoke (execute-chart-tests) is separate and
# deploys the chart onto a kind cluster.
.PHONY: helm-lint
helm-lint: ## Lint the chart.
helm lint helm/agent --values helm/agent/ci/ci-values.yaml
.PHONY: helm-template
helm-template: ## Render the chart with the CI values.
helm template agent helm/agent --values helm/agent/ci/ci-values.yaml
# Prerequisite-only, no recipe: make merges it into the generated helm-test
# rule, which keeps its recipe (the helm-unittest run) and gains the lint.
.PHONY: helm-test
helm-test: helm-lint helm-toolset-schema-test helm-require-approval-test
# Chart 3.0 refuses muster.requireApproval in its templates, not only in the
# values schema: a HelmRelease with disableSchemaValidation must not render the
# agent with neither kagent's flag nor default: Ask. helm-unittest validates
# the schema first, so this check renders with the schema skipped.
.PHONY: helm-require-approval-test
helm-require-approval-test:
@set -eu; \
for v in true false; do \
for extra in "" "--set muster.enabled=false" "--set toolset[0]=preset:none"; do \
if out=$$(helm template example helm/agent --kubeconfig /dev/null --skip-schema-validation \
--set-string modelConfig.name=schema-test --set muster.requireApproval=$$v $$extra 2>&1); then \
echo "FAIL: muster.requireApproval=$$v $$extra renders with the schema skipped"; exit 1; \
fi; \
echo "$$out" | grep -q 'muster.requireApproval was removed in agent chart 3.0' || { echo "$$out" >&2; exit 1; }; \
done; \
done; \
helm template example helm/agent --kubeconfig /dev/null --skip-schema-validation --set-string modelConfig.name=schema-test --set default=Ask >/dev/null
.PHONY: helm-toolset-schema-test
helm-toolset-schema-test:
@set -eu; \
scratch_root="$${TMPDIR:-$${HOME}/.cache/tmp}"; \
mkdir -p "$$scratch_root"; \
scratch=$$(mktemp -d "$$scratch_root/toolset-schema.XXXXXX"); \
trap 'rm -rf "$$scratch"' EXIT; \
for count in 128 129; do \
awk -v count="$$count" 'BEGIN { print "toolset:"; for (entry = 0; entry < count; entry++) printf " - tool:example_%d\n", entry }' > "$$scratch/values.yaml"; \
if helm template example helm/agent --kubeconfig /dev/null \
--set-string modelConfig.name=schema-test --values "$$scratch/values.yaml" \
> "$$scratch/rendered.yaml" 2> "$$scratch/error"; then \
test "$$count" -eq 128; \
else \
test "$$count" -eq 129 || { cat "$$scratch/error" >&2; exit 1; }; \
grep -Eq 'maxItems: got 129, want 128|at most 128 items' "$$scratch/error" || { cat "$$scratch/error" >&2; exit 1; }; \
fi; \
done
.PHONY: helm-unittest-update
helm-unittest-update: install-helm-unittest ## Re-record the golden snapshot in helm/agent/tests/__snapshot__/ (only on purpose; say so in the PR).
helm unittest -u helm/agent