From 7e89bde0f2a64d16a055d286aa30b2d06def1c23 Mon Sep 17 00:00:00 2001 From: hadar-co Date: Wed, 18 May 2022 14:32:00 +0300 Subject: [PATCH] fix utility output --- CODEOWNERS | 2 +- .../{kubectl-crd-extractor => crd-extractor} | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) rename crd-extractor/{kubectl-crd-extractor => crd-extractor} (51%) diff --git a/CODEOWNERS b/CODEOWNERS index fec57381..15830cea 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,2 @@ -# by deafult +# by default @datreeio/product diff --git a/crd-extractor/kubectl-crd-extractor b/crd-extractor/crd-extractor similarity index 51% rename from crd-extractor/kubectl-crd-extractor rename to crd-extractor/crd-extractor index ee1ee23b..ebdb59c0 100755 --- a/crd-extractor/kubectl-crd-extractor +++ b/crd-extractor/crd-extractor @@ -2,8 +2,14 @@ # Check if python3 is installed if ! command -v python3 &> /dev/null; then - printf "python3 is required for this plugin, and is not installed on your machine" - printf "please visit https://www.python.org/downloads/ and install it" + printf "python3 is required for this utility, and is not installed on your machine" + printf "please visit https://www.python.org/downloads/ to install it" + exit 1 +fi +# Check if kubectl is installed +if ! command -v python3 &> /dev/null; then + printf "kubectl is required for this utility, and is not installed on your machine" + printf "please visit https://kubernetes.io/docs/tasks/tools/#kubectl to install it" exit 1 fi @@ -33,9 +39,10 @@ python3 $TMP_CRD_DIR/openapi2jsonschema.py $TMP_CRD_DIR/*.yaml if [ $? == 0 ]; then printf "Successfully converted $NUM_OF_CRDS CRDs to JSON schema\n" - printf "To execute a Datree policy check against your CRs - run 'datree test --schema-location $HOME/.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json /path/to/file'\n" - printf "\nWould you like your public CRs to be checked automatically in the future? No problem! Add your schemas to our CRD-catalog and help us support popular CRs in future Datree policy checks :)\n" - printf "For more information visit https://www.github.com/datreeio/crds-catalog \n" + + printf "\nTo validate a CR using various tools, run the relevant command:\n" + printf "\n- kubeconform:\n\$kubeconform -summary -output json -schema-location default -schema-location '$HOME/.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json' /path/to/file\n" + printf "\n- datree:\n\$datree test --schema-location $HOME/.datree/crdSchemas/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json /path/to/file\n\n" fi rm -rf $TMP_CRD_DIR \ No newline at end of file