Fix python-crd-cmd.sh cli options and improve verbosity in preprocess (#235)

* Missed colon added

* pass client version added to options

* added verbosity to crd gen
This commit is contained in:
Dmitry Makhrovsky
2023-01-10 02:49:12 +03:00
committed by GitHub
parent ea5af85f5b
commit 39ed53daeb
2 changed files with 4 additions and 2 deletions

View File

@@ -174,6 +174,7 @@ def drop_paths(spec):
group_prefix_reversed = '.'.join(group_prefix.split('.')[::-1]) group_prefix_reversed = '.'.join(group_prefix.split('.')[::-1])
for k, v in spec['paths'].items(): for k, v in spec['paths'].items():
if k.startswith('/apis/' + group_prefix_reversed): if k.startswith('/apis/' + group_prefix_reversed):
print("Adding Custom Resource api path %s" %k)
paths[k] = v paths[k] = v
else: else:
print("Ignoring non Custom Resource api path %s" %k) print("Ignoring non Custom Resource api path %s" %k)
@@ -318,6 +319,7 @@ def filter_api_group(spec):
models = {} models = {}
for k, v in spec['definitions'].items(): for k, v in spec['definitions'].items():
if k.startswith(os.environ.get('KUBERNETES_CRD_GROUP_PREFIX')): if k.startswith(os.environ.get('KUBERNETES_CRD_GROUP_PREFIX')):
print("Adding Custom Resource by prefix %s" %k)
models[k] = v models[k] = v
elif k.startswith("io.k8s"): elif k.startswith("io.k8s"):
print("Removing builtin Kubernetes Resource %s" %k) print("Removing builtin Kubernetes Resource %s" %k)

4
openapi/python-crd-cmd.sh Normal file → Executable file
View File

@@ -20,9 +20,9 @@ print_usage() {
echo " -h: hide generation timestamp" >& 2 echo " -h: hide generation timestamp" >& 2
} }
while getopts 'c:g:h:n:l:p:o' flag; do while getopts 'c:g:h:n:l:p:o:' flag; do
case "${flag}" in case "${flag}" in
c) CLIENT_VERSION="${CLIENT_VERSION}" ;; c) CLIENT_VERSION="${OPTARG}" ;;
g) GENERATE_APIS="${OPTARG}" ;; g) GENERATE_APIS="${OPTARG}" ;;
h) HIDE_GENERATION_TIMESTAMP="${OPTARG}" ;; h) HIDE_GENERATION_TIMESTAMP="${OPTARG}" ;;
n) KUBERNETES_CRD_GROUP_PREFIX="${OPTARG}" ;; n) KUBERNETES_CRD_GROUP_PREFIX="${OPTARG}" ;;