Add JSON schema generation for kubeconform CRD validation
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/kubeconform Pipeline was successful

- ci/generate-schemas.sh extracts schemas from live cluster CRDs via kubectl
- Generated schemas committed to schemas/ for CI use
- Run `make schemas` to regenerate after CRD or K8s version changes
- validate-apps.sh and validate-clusters.sh check local schemas first
- CRD instances (Gateway, TLSRoute, Pooler, etc.) now validated instead of skipped
- CustomResourceDefinition meta-type still skipped (no schema exists upstream)
This commit is contained in:
2026-06-28 16:53:11 +10:00
parent cfca1e5278
commit 2bd8fcc0c2
264 changed files with 142907 additions and 2 deletions
+381
View File
@@ -0,0 +1,381 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"properties": {
"cluster": {
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"method": {
"default": "barmanObjectStore",
"enum": [
"barmanObjectStore",
"volumeSnapshot",
"plugin"
],
"type": "string"
},
"online": {
"type": "boolean"
},
"onlineConfiguration": {
"properties": {
"immediateCheckpoint": {
"type": "boolean"
},
"waitForArchive": {
"default": true,
"type": "boolean"
}
},
"type": "object"
},
"pluginConfiguration": {
"properties": {
"name": {
"type": "string"
},
"parameters": {
"additionalProperties": {
"type": "string"
},
"type": "object"
}
},
"required": [
"name"
],
"type": "object"
},
"target": {
"enum": [
"primary",
"prefer-standby"
],
"type": "string"
}
},
"required": [
"cluster"
],
"type": "object",
"x-kubernetes-validations": [
{
"message": "BackupSpec is immutable once set",
"rule": "oldSelf == self"
}
]
},
"status": {
"properties": {
"azureCredentials": {
"properties": {
"connectionString": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"inheritFromAzureAD": {
"type": "boolean"
},
"storageAccount": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"storageKey": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"storageSasToken": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
}
},
"type": "object"
},
"backupId": {
"type": "string"
},
"backupLabelFile": {
"format": "byte",
"type": "string"
},
"backupName": {
"type": "string"
},
"beginLSN": {
"type": "string"
},
"beginWal": {
"type": "string"
},
"commandError": {
"type": "string"
},
"commandOutput": {
"type": "string"
},
"destinationPath": {
"type": "string"
},
"encryption": {
"type": "string"
},
"endLSN": {
"type": "string"
},
"endWal": {
"type": "string"
},
"endpointCA": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"endpointURL": {
"type": "string"
},
"error": {
"type": "string"
},
"googleCredentials": {
"properties": {
"applicationCredentials": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"gkeEnvironment": {
"type": "boolean"
}
},
"type": "object"
},
"instanceID": {
"properties": {
"ContainerID": {
"type": "string"
},
"podName": {
"type": "string"
}
},
"type": "object"
},
"majorVersion": {
"type": "integer"
},
"method": {
"type": "string"
},
"online": {
"type": "boolean"
},
"phase": {
"type": "string"
},
"pluginMetadata": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"s3Credentials": {
"properties": {
"accessKeyId": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"inheritFromIAMRole": {
"type": "boolean"
},
"region": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"secretAccessKey": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
},
"sessionToken": {
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key",
"name"
],
"type": "object"
}
},
"type": "object"
},
"serverName": {
"type": "string"
},
"snapshotBackupStatus": {
"properties": {
"elements": {
"items": {
"properties": {
"name": {
"type": "string"
},
"tablespaceName": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"name",
"type"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
},
"startedAt": {
"format": "date-time",
"type": "string"
},
"stoppedAt": {
"format": "date-time",
"type": "string"
},
"tablespaceMapFile": {
"format": "byte",
"type": "string"
}
},
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,54 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"properties": {
"images": {
"items": {
"properties": {
"image": {
"type": "string"
},
"major": {
"minimum": 10,
"type": "integer"
}
},
"required": [
"image",
"major"
],
"type": "object"
},
"maxItems": 8,
"minItems": 1,
"type": "array",
"x-kubernetes-validations": [
{
"message": "Images must have unique major versions",
"rule": "self.all(e, self.filter(f, f.major==e.major).size() == 1)"
}
]
}
},
"required": [
"images"
],
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}
+518
View File
@@ -0,0 +1,518 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"properties": {
"allowConnections": {
"type": "boolean"
},
"builtinLocale": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "builtinLocale is immutable",
"rule": "self == oldSelf"
}
]
},
"cluster": {
"properties": {
"name": {
"default": "",
"type": "string"
}
},
"type": "object",
"x-kubernetes-map-type": "atomic"
},
"collationVersion": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "collationVersion is immutable",
"rule": "self == oldSelf"
}
]
},
"connectionLimit": {
"type": "integer"
},
"databaseReclaimPolicy": {
"default": "retain",
"enum": [
"delete",
"retain"
],
"type": "string"
},
"encoding": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "encoding is immutable",
"rule": "self == oldSelf"
}
]
},
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"extensions": {
"items": {
"properties": {
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"name": {
"type": "string"
},
"schema": {
"type": "string"
},
"version": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
},
"fdws": {
"items": {
"properties": {
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"handler": {
"type": "string"
},
"name": {
"type": "string"
},
"options": {
"items": {
"properties": {
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"name",
"value"
],
"type": "object"
},
"type": "array"
},
"owner": {
"type": "string"
},
"usage": {
"items": {
"properties": {
"name": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "name is required",
"rule": "self != ''"
}
]
},
"type": {
"default": "grant",
"enum": [
"grant",
"revoke"
],
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
},
"validator": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
},
"icuLocale": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "icuLocale is immutable",
"rule": "self == oldSelf"
}
]
},
"icuRules": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "icuRules is immutable",
"rule": "self == oldSelf"
}
]
},
"isTemplate": {
"type": "boolean"
},
"locale": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "locale is immutable",
"rule": "self == oldSelf"
}
]
},
"localeCType": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "localeCType is immutable",
"rule": "self == oldSelf"
}
]
},
"localeCollate": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "localeCollate is immutable",
"rule": "self == oldSelf"
}
]
},
"localeProvider": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "localeProvider is immutable",
"rule": "self == oldSelf"
}
]
},
"name": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "name is immutable",
"rule": "self == oldSelf"
},
{
"message": "the name postgres is reserved",
"rule": "self != 'postgres'"
},
{
"message": "the name template0 is reserved",
"rule": "self != 'template0'"
},
{
"message": "the name template1 is reserved",
"rule": "self != 'template1'"
}
]
},
"owner": {
"type": "string"
},
"schemas": {
"items": {
"properties": {
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"name": {
"type": "string"
},
"owner": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
},
"servers": {
"items": {
"properties": {
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"fdw": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "fdw is required",
"rule": "self != ''"
}
]
},
"name": {
"type": "string"
},
"options": {
"items": {
"properties": {
"ensure": {
"default": "present",
"enum": [
"present",
"absent"
],
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"name",
"value"
],
"type": "object"
},
"type": "array"
},
"usage": {
"items": {
"properties": {
"name": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "name is required",
"rule": "self != ''"
}
]
},
"type": {
"default": "grant",
"enum": [
"grant",
"revoke"
],
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"fdw",
"name"
],
"type": "object"
},
"type": "array"
},
"tablespace": {
"type": "string"
},
"template": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "template is immutable",
"rule": "self == oldSelf"
}
]
}
},
"required": [
"cluster",
"name",
"owner"
],
"type": "object",
"x-kubernetes-validations": [
{
"message": "builtinLocale is only available when localeProvider is set to `builtin`",
"rule": "!has(self.builtinLocale) || self.localeProvider == 'builtin'"
},
{
"message": "icuLocale is only available when localeProvider is set to `icu`",
"rule": "!has(self.icuLocale) || self.localeProvider == 'icu'"
},
{
"message": "icuRules is only available when localeProvider is set to `icu`",
"rule": "!has(self.icuRules) || self.localeProvider == 'icu'"
}
]
},
"status": {
"properties": {
"applied": {
"type": "boolean"
},
"extensions": {
"items": {
"properties": {
"applied": {
"type": "boolean"
},
"message": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"applied",
"name"
],
"type": "object"
},
"type": "array"
},
"fdws": {
"items": {
"properties": {
"applied": {
"type": "boolean"
},
"message": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"applied",
"name"
],
"type": "object"
},
"type": "array"
},
"message": {
"type": "string"
},
"observedGeneration": {
"format": "int64",
"type": "integer"
},
"schemas": {
"items": {
"properties": {
"applied": {
"type": "boolean"
},
"message": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"applied",
"name"
],
"type": "object"
},
"type": "array"
},
"servers": {
"items": {
"properties": {
"applied": {
"type": "boolean"
},
"message": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"applied",
"name"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}
@@ -0,0 +1,38 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"status": {
"properties": {
"method": {
"type": "string"
},
"primary": {
"type": "string"
},
"standbyNames": {
"items": {
"type": "string"
},
"type": "array"
},
"standbyNumber": {
"type": "integer"
}
},
"type": "object"
}
},
"required": [
"metadata"
],
"type": "object"
}
@@ -0,0 +1,54 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"properties": {
"images": {
"items": {
"properties": {
"image": {
"type": "string"
},
"major": {
"minimum": 10,
"type": "integer"
}
},
"required": [
"image",
"major"
],
"type": "object"
},
"maxItems": 8,
"minItems": 1,
"type": "array",
"x-kubernetes-validations": [
{
"message": "Images must have unique major versions",
"rule": "self.all(e, self.filter(f, f.major==e.major).size() == 1)"
}
]
}
},
"required": [
"images"
],
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,154 @@
{
"$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"
}
@@ -0,0 +1,122 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"properties": {
"backupOwnerReference": {
"default": "none",
"enum": [
"none",
"self",
"cluster"
],
"type": "string"
},
"cluster": {
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"immediate": {
"type": "boolean"
},
"method": {
"default": "barmanObjectStore",
"enum": [
"barmanObjectStore",
"volumeSnapshot",
"plugin"
],
"type": "string"
},
"online": {
"type": "boolean"
},
"onlineConfiguration": {
"properties": {
"immediateCheckpoint": {
"type": "boolean"
},
"waitForArchive": {
"default": true,
"type": "boolean"
}
},
"type": "object"
},
"pluginConfiguration": {
"properties": {
"name": {
"type": "string"
},
"parameters": {
"additionalProperties": {
"type": "string"
},
"type": "object"
}
},
"required": [
"name"
],
"type": "object"
},
"schedule": {
"type": "string"
},
"suspend": {
"type": "boolean"
},
"target": {
"enum": [
"primary",
"prefer-standby"
],
"type": "string"
}
},
"required": [
"cluster",
"schedule"
],
"type": "object"
},
"status": {
"properties": {
"lastCheckTime": {
"format": "date-time",
"type": "string"
},
"lastScheduleTime": {
"format": "date-time",
"type": "string"
},
"nextScheduleTime": {
"format": "date-time",
"type": "string"
}
},
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}
@@ -0,0 +1,97 @@
{
"$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"
}
]
},
"externalClusterName": {
"type": "string"
},
"name": {
"type": "string",
"x-kubernetes-validations": [
{
"message": "name is immutable",
"rule": "self == oldSelf"
}
]
},
"parameters": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"publicationDBName": {
"type": "string"
},
"publicationName": {
"type": "string"
},
"subscriptionReclaimPolicy": {
"default": "retain",
"enum": [
"delete",
"retain"
],
"type": "string"
}
},
"required": [
"cluster",
"dbname",
"externalClusterName",
"name",
"publicationName"
],
"type": "object"
},
"status": {
"properties": {
"applied": {
"type": "boolean"
},
"message": {
"type": "string"
},
"observedGeneration": {
"format": "int64",
"type": "integer"
}
},
"type": "object"
}
},
"required": [
"metadata",
"spec"
],
"type": "object"
}