mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-23 19:57:02 +00:00
scripts: Check versions before version
CRD versions can have multiple schemas, but they can also share the same. https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#specify-multiple-versions
This commit is contained in:
parent
f8ffb2f9e3
commit
c489a69a4c
1 changed files with 19 additions and 10 deletions
|
|
@ -123,16 +123,7 @@ for crdFile in sys.argv[1:]:
|
||||||
|
|
||||||
filename_format = os.getenv("FILENAME_FORMAT", "{kind}_{version}")
|
filename_format = os.getenv("FILENAME_FORMAT", "{kind}_{version}")
|
||||||
filename = ""
|
filename = ""
|
||||||
if "spec" in y and "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]:
|
if "spec" in y and "versions" in y["spec"] and y["spec"]["versions"]:
|
||||||
filename = filename_format.format(
|
|
||||||
kind=y["spec"]["names"]["kind"],
|
|
||||||
group=y["spec"]["group"].split(".")[0],
|
|
||||||
version=y["spec"]["version"],
|
|
||||||
).lower() + ".json"
|
|
||||||
|
|
||||||
schema = y["spec"]["validation"]["openAPIV3Schema"]
|
|
||||||
write_schema_file(schema, filename)
|
|
||||||
elif "spec" in y and "versions" in y["spec"]:
|
|
||||||
for version in y["spec"]["versions"]:
|
for version in y["spec"]["versions"]:
|
||||||
if "schema" in version and "openAPIV3Schema" in version["schema"]:
|
if "schema" in version and "openAPIV3Schema" in version["schema"]:
|
||||||
filename = filename_format.format(
|
filename = filename_format.format(
|
||||||
|
|
@ -143,5 +134,23 @@ for crdFile in sys.argv[1:]:
|
||||||
|
|
||||||
schema = version["schema"]["openAPIV3Schema"]
|
schema = version["schema"]["openAPIV3Schema"]
|
||||||
write_schema_file(schema, filename)
|
write_schema_file(schema, filename)
|
||||||
|
elif "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]:
|
||||||
|
filename = filename_format.format(
|
||||||
|
kind=y["spec"]["names"]["kind"],
|
||||||
|
group=y["spec"]["group"].split(".")[0],
|
||||||
|
version=version["name"],
|
||||||
|
).lower() + ".json"
|
||||||
|
|
||||||
|
schema = y["spec"]["validation"]["openAPIV3Schema"]
|
||||||
|
write_schema_file(schema, filename)
|
||||||
|
elif "spec" in y and "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]:
|
||||||
|
filename = filename_format.format(
|
||||||
|
kind=y["spec"]["names"]["kind"],
|
||||||
|
group=y["spec"]["group"].split(".")[0],
|
||||||
|
version=y["spec"]["version"],
|
||||||
|
).lower() + ".json"
|
||||||
|
|
||||||
|
schema = y["spec"]["validation"]["openAPIV3Schema"]
|
||||||
|
write_schema_file(schema, filename)
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue