Files
unkinben 784c3b5de1 Add JSON schema generation for kubeconform CRD validation (#212)
## Summary
- New `ci/generate-schemas.sh` script that generates JSON schemas from three sources:
  1. Live cluster CRDs via `kubectl get crds`
  2. Offline CRD manifests (ArgoCD v3.3.2, Gateway API v1.5.1)
  3. Kubernetes v1.33.7 swagger spec for native types
- Schemas follow Datree catalog convention (`<group>/<Kind>_<version>.json`)
- `validate-apps.sh` and `validate-clusters.sh` check local schemas first, falling back to remote
- Fixes TLSRoute (and other CRD) schema validation failures in kubeconform

## Sources
- ArgoCD: `artifactapi.../argoproj/argo-cd/refs/tags/v3.3.2/manifests/ha/install.yaml`
- Gateway API: `artifactapi.../kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yaml`
- Kubernetes: `artifactapi.../kubernetes/kubernetes/refs/tags/v1.33.7/api/openapi-spec/swagger.json`

Reviewed-on: #212
Co-authored-by: Ben Vincent <ben@unkin.net>
Co-committed-by: Ben Vincent <ben@unkin.net>
2026-06-28 17:26:08 +10:00

155 lines
4.0 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"properties": {
"cluster": {
"properties": {
"name": {
"default": "",
"type": "string"
}
},
"type": "object",
"x-kubernetes-map-type": "atomic"
},
"dbname": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "dbname is immutable",
"rule": "self == oldSelf"
}
]
},
"name": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "name is immutable",
"rule": "self == oldSelf"
}
]
},
"parameters": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"publicationReclaimPolicy": {
"default": "retain",
"enum": [
"delete",
"retain"
],
"type": "string"
},
"target": {
"properties": {
"allTables": {
"type": "boolean",
"x-kubernetes-validations": [
{
"message": "allTables is immutable",
"rule": "self == oldSelf"
}
]
},
"objects": {
"items": {
"properties": {
"table": {
"properties": {
"columns": {
"items": {
"type": "string"
},
"type": "array"
},
"name": {
"type": "string"
},
"only": {
"type": "boolean"
},
"schema": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"tablesInSchema": {
"type": "string"
}
},
"type": "object",
"x-kubernetes-validations": [
{
"message": "tablesInSchema and table are mutually exclusive",
"rule": "(has(self.tablesInSchema) && !has(self.table)) || (!has(self.tablesInSchema) && has(self.table))"
}
]
},
"maxItems": 100000,
"type": "array",
"x-kubernetes-validations": [
{
"message": "specifying a column list when the publication also publishes tablesInSchema is not supported",
"rule": "!(self.exists(o, has(o.table) && has(o.table.columns)) && self.exists(o, has(o.tablesInSchema)))"
}
]
}
},
"type": "object",
"x-kubernetes-validations": [
{
"message": "allTables and objects are mutually exclusive",
"rule": "(has(self.allTables) && !has(self.objects)) || (!has(self.allTables) && has(self.objects))"
}
]
}
},
"required": [
"cluster",
"dbname",
"name",
"target"
],
"type": "object"
},
"status": {
"properties": {
"applied": {
"type": "boolean"
},
"message": {
"type": "string"
},
"observedGeneration": {
"format": "int64",
"type": "integer"
}
},
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}