File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626 let NUM_OF_CRDS++
2727done < <( kubectl get crds 2>&1 | tail -n +2)
2828
29+ # If no CRDs exist in the cluster, exit
30+ if [ $NUM_OF_CRDS == 0 ]; then
31+ printf " No CRDs found in your cluster, exiting...\n"
32+ exit 0
33+ fi
34+
2935# Download converter script
3036curl https://raw.githubusercontent.com/yannh/kubeconform/master/scripts/openapi2jsonschema.py --output $TMP_CRD_DIR /openapi2jsonschema.py 2> /dev/null
3137
@@ -37,12 +43,16 @@ cd $SCHEMAS_DIR
3743# Convert crds to jsonSchema
3844python3 $TMP_CRD_DIR /openapi2jsonschema.py $TMP_CRD_DIR /* .yaml
3945
46+ CYAN=' \033[0;36m'
47+ GREEN=' \033[0;32m'
48+ NC=' \033[0m' # No Color
49+
4050if [ $? == 0 ]; then
41- printf " Successfully converted $NUM_OF_CRDS CRDs to JSON schema\n"
51+ printf " ${GREEN} Successfully converted $NUM_OF_CRDS CRDs to JSON schema${NC} \n"
4252
4353 printf " \nTo validate a CR using various tools, run the relevant command:\n"
44- printf " \n- kubeconform:\n\$ kubeconform -summary -output json -schema-location default -schema-location '$HOME /.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json' /path/to/file\n"
45- printf " \n- datree:\n\$ datree test --schema-location $HOME /.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json /path/to/file\n\n"
54+ printf " \n- ${CYAN} kubeconform:${NC} \n\$ kubeconform -summary -output json -schema-location default -schema-location '$HOME /.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json' /path/to/file\n"
55+ printf " \n- ${CYAN} datree:${NC} \n\$ datree test --schema-location $HOME /.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json /path/to/file\n\n"
4656fi
4757
4858rm -rf $TMP_CRD_DIR
You can’t perform that action at this time.
0 commit comments