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>
This commit was merged in pull request #212.
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"spec": {
|
||||
"properties": {
|
||||
"source": {
|
||||
"properties": {
|
||||
"persistentVolumeClaimName": {
|
||||
"type": "string",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "persistentVolumeClaimName is immutable",
|
||||
"rule": "self == oldSelf"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumeSnapshotContentName": {
|
||||
"type": "string",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "volumeSnapshotContentName is immutable",
|
||||
"rule": "self == oldSelf"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "persistentVolumeClaimName is required once set",
|
||||
"rule": "!has(oldSelf.persistentVolumeClaimName) || has(self.persistentVolumeClaimName)"
|
||||
},
|
||||
{
|
||||
"message": "volumeSnapshotContentName is required once set",
|
||||
"rule": "!has(oldSelf.volumeSnapshotContentName) || has(self.volumeSnapshotContentName)"
|
||||
},
|
||||
{
|
||||
"message": "exactly one of volumeSnapshotContentName and persistentVolumeClaimName must be set",
|
||||
"rule": "(has(self.volumeSnapshotContentName) && !has(self.persistentVolumeClaimName)) || (!has(self.volumeSnapshotContentName) && has(self.persistentVolumeClaimName))"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumeSnapshotClassName": {
|
||||
"type": "string",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "volumeSnapshotClassName must not be the empty string when set",
|
||||
"rule": "size(self) > 0"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"source"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"status": {
|
||||
"properties": {
|
||||
"boundVolumeSnapshotContentName": {
|
||||
"type": "string"
|
||||
},
|
||||
"creationTime": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"time": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"readyToUse": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"restoreSize": {
|
||||
"pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
|
||||
"type": "string",
|
||||
"x-kubernetes-int-or-string": true
|
||||
},
|
||||
"volumeGroupSnapshotName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"spec"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"spec": {
|
||||
"properties": {
|
||||
"source": {
|
||||
"properties": {
|
||||
"persistentVolumeClaimName": {
|
||||
"type": "string"
|
||||
},
|
||||
"volumeSnapshotContentName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"volumeSnapshotClassName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"source"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"status": {
|
||||
"properties": {
|
||||
"boundVolumeSnapshotContentName": {
|
||||
"type": "string"
|
||||
},
|
||||
"creationTime": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"time": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"readyToUse": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"restoreSize": {
|
||||
"pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
|
||||
"type": "string",
|
||||
"x-kubernetes-int-or-string": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"spec"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"deletionPolicy": {
|
||||
"enum": [
|
||||
"Delete",
|
||||
"Retain"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"driver": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"parameters": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deletionPolicy",
|
||||
"driver"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"deletionPolicy": {
|
||||
"enum": [
|
||||
"Delete",
|
||||
"Retain"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"driver": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"parameters": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deletionPolicy",
|
||||
"driver"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"spec": {
|
||||
"properties": {
|
||||
"deletionPolicy": {
|
||||
"enum": [
|
||||
"Delete",
|
||||
"Retain"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"driver": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"properties": {
|
||||
"snapshotHandle": {
|
||||
"type": "string",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "snapshotHandle is immutable",
|
||||
"rule": "self == oldSelf"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumeHandle": {
|
||||
"type": "string",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "volumeHandle is immutable",
|
||||
"rule": "self == oldSelf"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "volumeHandle is required once set",
|
||||
"rule": "!has(oldSelf.volumeHandle) || has(self.volumeHandle)"
|
||||
},
|
||||
{
|
||||
"message": "snapshotHandle is required once set",
|
||||
"rule": "!has(oldSelf.snapshotHandle) || has(self.snapshotHandle)"
|
||||
},
|
||||
{
|
||||
"message": "exactly one of volumeHandle and snapshotHandle must be set",
|
||||
"rule": "(has(self.volumeHandle) && !has(self.snapshotHandle)) || (!has(self.volumeHandle) && has(self.snapshotHandle))"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceVolumeMode": {
|
||||
"type": "string",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "sourceVolumeMode is immutable",
|
||||
"rule": "self == oldSelf"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumeSnapshotClassName": {
|
||||
"type": "string"
|
||||
},
|
||||
"volumeSnapshotRef": {
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string"
|
||||
},
|
||||
"resourceVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"uid": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"x-kubernetes-map-type": "atomic",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "both spec.volumeSnapshotRef.name and spec.volumeSnapshotRef.namespace must be set",
|
||||
"rule": "has(self.name) && has(self.__namespace__)"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deletionPolicy",
|
||||
"driver",
|
||||
"source",
|
||||
"volumeSnapshotRef"
|
||||
],
|
||||
"type": "object",
|
||||
"x-kubernetes-validations": [
|
||||
{
|
||||
"message": "sourceVolumeMode is required once set",
|
||||
"rule": "!has(oldSelf.sourceVolumeMode) || has(self.sourceVolumeMode)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"properties": {
|
||||
"creationTime": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"error": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"time": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"readyToUse": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"restoreSize": {
|
||||
"format": "int64",
|
||||
"minimum": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"snapshotHandle": {
|
||||
"type": "string"
|
||||
},
|
||||
"volumeGroupSnapshotHandle": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"spec"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"spec": {
|
||||
"properties": {
|
||||
"deletionPolicy": {
|
||||
"enum": [
|
||||
"Delete",
|
||||
"Retain"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"driver": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"properties": {
|
||||
"snapshotHandle": {
|
||||
"type": "string"
|
||||
},
|
||||
"volumeHandle": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"volumeSnapshotClassName": {
|
||||
"type": "string"
|
||||
},
|
||||
"volumeSnapshotRef": {
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string"
|
||||
},
|
||||
"resourceVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"uid": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deletionPolicy",
|
||||
"driver",
|
||||
"source",
|
||||
"volumeSnapshotRef"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"status": {
|
||||
"properties": {
|
||||
"creationTime": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"error": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"time": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"readyToUse": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"restoreSize": {
|
||||
"format": "int64",
|
||||
"minimum": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"snapshotHandle": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"spec"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
Reference in New Issue
Block a user