Skip to content

Commit 707ba79

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

File tree

2 files changed

+185
-1
lines changed

2 files changed

+185
-1
lines changed

Makefile

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
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 "Generating Helm chart values schema..."
55+
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
56+
@helm plugin list | grep -q "schema" || { echo "Installing helm-values-schema-json plugin..."; helm plugin install https://github.com/losisin/helm-values-schema-json; }
57+
@cd deploy/cert-manager-sync && helm schema -f values.yaml -o values.schema.json
58+
@echo "Schema updated successfully at deploy/cert-manager-sync/values.schema.json"
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"properties": {
5+
"affinity": {
6+
"type": "object"
7+
},
8+
"autoscaling": {
9+
"type": "object",
10+
"properties": {
11+
"enabled": {
12+
"type": "boolean"
13+
},
14+
"maxReplicas": {
15+
"type": "integer"
16+
},
17+
"minReplicas": {
18+
"type": "integer"
19+
},
20+
"targetCPUUtilizationPercentage": {
21+
"type": "integer"
22+
}
23+
}
24+
},
25+
"clusterRole": {
26+
"type": "object",
27+
"properties": {
28+
"create": {
29+
"type": "boolean"
30+
}
31+
}
32+
},
33+
"config": {
34+
"type": "object",
35+
"properties": {
36+
"disableCache": {
37+
"type": "string"
38+
},
39+
"disabledNamespaces": {
40+
"type": "string"
41+
},
42+
"enabledNamespaces": {
43+
"type": "string"
44+
},
45+
"logFormat": {
46+
"type": "string"
47+
},
48+
"logLevel": {
49+
"type": "string"
50+
},
51+
"operatorName": {
52+
"type": "string"
53+
},
54+
"secretsNamespace": {
55+
"type": "string"
56+
}
57+
}
58+
},
59+
"env": {
60+
"type": "array"
61+
},
62+
"fullnameOverride": {
63+
"type": "string"
64+
},
65+
"image": {
66+
"type": "object",
67+
"properties": {
68+
"pullPolicy": {
69+
"type": "string"
70+
},
71+
"repository": {
72+
"type": "string"
73+
},
74+
"tag": {
75+
"type": "string"
76+
}
77+
}
78+
},
79+
"imagePullSecrets": {
80+
"type": "array"
81+
},
82+
"metrics": {
83+
"type": "object",
84+
"properties": {
85+
"enabled": {
86+
"type": "boolean"
87+
},
88+
"port": {
89+
"type": "integer"
90+
}
91+
}
92+
},
93+
"nameOverride": {
94+
"type": "string"
95+
},
96+
"nodeSelector": {
97+
"type": "object"
98+
},
99+
"podAnnotations": {
100+
"type": "object"
101+
},
102+
"podSecurityContext": {
103+
"type": "object"
104+
},
105+
"replicaCount": {
106+
"type": "integer"
107+
},
108+
"resources": {
109+
"type": "object"
110+
},
111+
"securityContext": {
112+
"type": "object"
113+
},
114+
"serviceAccount": {
115+
"type": "object",
116+
"properties": {
117+
"annotations": {
118+
"type": "object"
119+
},
120+
"create": {
121+
"type": "boolean"
122+
},
123+
"name": {
124+
"type": "string"
125+
}
126+
}
127+
},
128+
"tolerations": {
129+
"type": "array"
130+
}
131+
}
132+
}

0 commit comments

Comments
 (0)