Skip to content

Commit 7925c30

Browse files
feat(helm): add schema file and corresponding makefile commands
1 parent 64e67cc commit 7925c30

File tree

2 files changed

+483
-1
lines changed

2 files changed

+483
-1
lines changed

Makefile

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
11

2+
# Makefile for cert-manager-sync
3+
#
4+
# Available targets:
5+
# test - Run Go tests and vulnerability checks
6+
# helm-validate-template - Validate Helm chart templates with kubeconform
7+
# helm-validate-schema - Validate Helm chart values against JSON schema
8+
# helm-validate-custom-values - Validate custom values file (requires VALUES_FILE)
9+
# helm-validate-all - Run comprehensive Helm chart validation
10+
# helm-update-schema - Update values.schema.json from values.yaml
11+
212
.PHONY: test
313
test:
414
@echo "Running tests..."
515
@go test -v ./...
6-
@govulncheck -show verbose ./...
16+
@govulncheck -show verbose ./...
17+
18+
.PHONY: helm-validate-template
19+
helm-validate-template:
20+
@echo "Validating Helm chart templates..."
21+
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
22+
@command -v kubeconform >/dev/null 2>&1 || { echo "kubeconform is required but not installed. Install it with: go install github.com/yannh/kubeconform/cmd/kubeconform@latest"; exit 1; }
23+
@helm template cert-manager-sync ./deploy/cert-manager-sync | kubeconform -strict -verbose
24+
25+
.PHONY: helm-validate-schema
26+
helm-validate-schema:
27+
@echo "Validating Helm chart values against JSON schema..."
28+
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
29+
@command -v yq >/dev/null 2>&1 || { echo "yq is required but not installed. Install it with: go install github.com/mikefarah/yq/v4@latest"; exit 1; }
30+
@command -v ajv >/dev/null 2>&1 || { echo "ajv-cli is required but not installed. Install it with: npm install -g ajv-cli"; exit 1; }
31+
@helm show values ./deploy/cert-manager-sync | yq eval -o=json | ajv validate -s ./deploy/cert-manager-sync/values.schema.json
32+
33+
.PHONY: helm-validate-custom-values
34+
helm-validate-custom-values:
35+
@echo "Comprehensive validation of custom values file..."
36+
@if [ -z "$(VALUES_FILE)" ]; then echo "Usage: make helm-validate-custom-values VALUES_FILE=path/to/values.yaml"; exit 1; fi
37+
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
38+
@command -v kubeconform >/dev/null 2>&1 || { echo "kubeconform is required but not installed. Install it with: go install github.com/yannh/kubeconform/cmd/kubeconform@latest"; exit 1; }
39+
@command -v yq >/dev/null 2>&1 || { echo "yq is required but not installed. Install it with: go install github.com/mikefarah/yq/v4@latest"; exit 1; }
40+
@command -v ajv >/dev/null 2>&1 || { echo "ajv-cli is required but not installed. Install it with: npm install -g ajv-cli"; exit 1; }
41+
@echo "Validating values schema..."
42+
@yq eval -o=json $(VALUES_FILE) | ajv validate -s ./deploy/cert-manager-sync/values.schema.json
43+
@echo "Validating generated templates..."
44+
@helm template cert-manager-sync ./deploy/cert-manager-sync --values $(VALUES_FILE) | kubeconform -strict -verbose
45+
@echo "Custom values validation passed!"
46+
47+
.PHONY: helm-validate-all
48+
helm-validate-all: helm-validate-template helm-validate-schema
49+
@echo "Running comprehensive Helm chart validation..."
50+
@echo "Note: To validate custom values, run: make helm-validate-custom-values VALUES_FILE=your-values.yaml"
51+
52+
.PHONY: helm-update-schema
53+
helm-update-schema:
54+
@echo "Updating Helm chart values schema..."
55+
@command -v helm-schema >/dev/null 2>&1 || { echo "helm-schema is required but not installed. Install it with: go install github.com/dadav/helm-schema/cmd/helm-schema@latest"; exit 1; }
56+
@helm-schema -c deploy -f values.yaml -o values.schema.json
57+
@echo "Schema updated successfully at deploy/cert-manager-sync/values.schema.json"

0 commit comments

Comments
 (0)