From 86106b9293311d95c6326f7d86beac364162e0b7 Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Sat, 17 Oct 2020 16:54:58 +0200 Subject: [PATCH] update openapi2schema script --- cmd/kubeconform/main.go | 2 +- cmd/openapi2jsonschema/main.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/kubeconform/main.go b/cmd/kubeconform/main.go index a9e2a7a..82f0fb8 100644 --- a/cmd/kubeconform/main.go +++ b/cmd/kubeconform/main.go @@ -263,7 +263,7 @@ func realMain() int { var o output.Output if o, err = getLogger(outputFormat, summary, verbose); err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) return 1 } diff --git a/cmd/openapi2jsonschema/main.py b/cmd/openapi2jsonschema/main.py index b0716d8..746f9d8 100755 --- a/cmd/openapi2jsonschema/main.py +++ b/cmd/openapi2jsonschema/main.py @@ -2,6 +2,7 @@ import yaml import json +import sys def iteritems(d): if hasattr(dict, "iteritems"): @@ -83,9 +84,15 @@ def append_no_duplicates(obj, key, value): if value not in obj[key]: obj[key].append(value) -with open(r'synced_secrets.yaml') as f: + +if len(sys.argv) == 0: + print("missing file") + exit(1) + +with open(sys.argv[1]) as f: y = yaml.load(f, Loader=yaml.SafeLoader) schema = y["spec"]["validation"]["openAPIV3Schema"] schema = additional_properties(schema) schema = replace_int_or_string(schema) - print(json.dumps(schema)) \ No newline at end of file + print(json.dumps(schema)) + exit(0)