Also support items elements in yaml, e.g. for kubectl get crds -o yaml

This commit is contained in:
Patrick Ruckstuhl 2021-09-25 01:09:08 +02:00
parent 4544f45fa1
commit 9228dba915

View file

@ -113,14 +113,20 @@ for crdFile in sys.argv[1:]:
else:
f = open(crdFile)
with f:
defs = []
for y in yaml.load_all(f, Loader=yaml.SafeLoader):
if y is None:
continue
if "items" in y:
defs.extend(y["items"])
if "kind" not in y:
continue
if y["kind"] != "CustomResourceDefinition":
continue
else:
defs.append(y)
for y in defs:
filename_format = os.getenv("FILENAME_FORMAT", "{kind}_{version}")
filename = ""
if "spec" in y and "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]: