Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@

# Makefile for cert-manager-sync
#
# Available targets:
# test - Run Go tests and vulnerability checks
# helm-validate-template - Validate Helm chart templates with kubeconform
# helm-validate-schema - Validate Helm chart values against JSON schema
# helm-validate-custom-values - Validate custom values file (requires VALUES_FILE)
# helm-validate-all - Run comprehensive Helm chart validation
# helm-update-schema - Update values.schema.json from values.yaml

.PHONY: test
test:
@echo "Running tests..."
@go test -v ./...
@govulncheck -show verbose ./...
@govulncheck -show verbose ./...

.PHONY: helm-validate-template
helm-validate-template:
@echo "Validating Helm chart templates..."
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
@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; }
@helm template cert-manager-sync ./deploy/cert-manager-sync | kubeconform -strict -verbose

.PHONY: helm-validate-schema
helm-validate-schema:
@echo "Validating Helm chart values against JSON schema..."
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
@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; }
@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; }
@helm show values ./deploy/cert-manager-sync | yq eval -o=json | ajv validate -s ./deploy/cert-manager-sync/values.schema.json

.PHONY: helm-validate-custom-values
helm-validate-custom-values:
@echo "Comprehensive validation of custom values file..."
@if [ -z "$(VALUES_FILE)" ]; then echo "Usage: make helm-validate-custom-values VALUES_FILE=path/to/values.yaml"; exit 1; fi
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
@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; }
@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; }
@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; }
@echo "Validating values schema..."
@yq eval -o=json $(VALUES_FILE) | ajv validate -s ./deploy/cert-manager-sync/values.schema.json
@echo "Validating generated templates..."
@helm template cert-manager-sync ./deploy/cert-manager-sync --values $(VALUES_FILE) | kubeconform -strict -verbose
@echo "Custom values validation passed!"

.PHONY: helm-validate-all
helm-validate-all: helm-validate-template helm-validate-schema
@echo "Running comprehensive Helm chart validation..."
@echo "Note: To validate custom values, run: make helm-validate-custom-values VALUES_FILE=your-values.yaml"

.PHONY: helm-update-schema
helm-update-schema:
@echo "Generating Helm chart values schema..."
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed. Please install Helm."; exit 1; }
@helm plugin list | grep -q "schema" || { echo "Installing helm-values-schema-json plugin..."; helm plugin install https://github.com/losisin/helm-values-schema-json; }
@cd deploy/cert-manager-sync && helm schema -f values.yaml -o values.schema.json
@echo "Schema updated successfully at deploy/cert-manager-sync/values.schema.json"
132 changes: 132 additions & 0 deletions deploy/cert-manager-sync/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"affinity": {
"type": "object"
},
"autoscaling": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"maxReplicas": {
"type": "integer"
},
"minReplicas": {
"type": "integer"
},
"targetCPUUtilizationPercentage": {
"type": "integer"
}
}
},
"clusterRole": {
"type": "object",
"properties": {
"create": {
"type": "boolean"
}
}
},
"config": {
"type": "object",
"properties": {
"disableCache": {
"type": "string"
},
"disabledNamespaces": {
"type": "string"
},
"enabledNamespaces": {
"type": "string"
},
"logFormat": {
"type": "string"
},
"logLevel": {
"type": "string"
},
"operatorName": {
"type": "string"
},
"secretsNamespace": {
"type": "string"
}
}
},
"env": {
"type": "array"
},
"fullnameOverride": {
"type": "string"
},
"image": {
"type": "object",
"properties": {
"pullPolicy": {
"type": "string"
},
"repository": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"imagePullSecrets": {
"type": "array"
},
"metrics": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"port": {
"type": "integer"
}
}
},
"nameOverride": {
"type": "string"
},
"nodeSelector": {
"type": "object"
},
"podAnnotations": {
"type": "object"
},
"podSecurityContext": {
"type": "object"
},
"replicaCount": {
"type": "integer"
},
"resources": {
"type": "object"
},
"securityContext": {
"type": "object"
},
"serviceAccount": {
"type": "object",
"properties": {
"annotations": {
"type": "object"
},
"create": {
"type": "boolean"
},
"name": {
"type": "string"
}
}
},
"tolerations": {
"type": "array"
}
}
}