From 9c88194e965b8f6752b2248d7bc220f1f23a8432 Mon Sep 17 00:00:00 2001 From: hadar-co Date: Sun, 13 Feb 2022 16:19:10 +0200 Subject: [PATCH] optimize fetch, add version --- kubectl-datree | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kubectl-datree b/kubectl-datree index 19de0c4..2393a6d 100755 --- a/kubectl-datree +++ b/kubectl-datree @@ -15,14 +15,18 @@ show_help(){ printf "\nDatree CLI args:\n" printf " This plugin supports all of the Datree CLI arguments: https://hub.datree.io/cli-arguments\n" printf "\nOptions:\n" - printf " [--namespace ] Test all resources in the cluster belonging to the specified namespace\n" + printf " [-n ] Test all resources in the cluster belonging to the specified namespace\n" printf " [ ] Test a single given resource in the cluster\n" - printf "\nRunning 'kubectl datree test' with no arguments is equivalent to 'kubectl datree test -- --namespace default'\n" + printf "\nRunning 'kubectl datree test' with no arguments is equivalent to 'kubectl datree test -- -n default'\n" } +PLUGIN_VERSION="v0.0.7" + # Validate argument -if [ "$1" != "test" ] -then +if [ "$1" == "version" ]; then + echo "kubectl-datree plugin version: $PLUGIN_VERSION" + exit 0 +elif [ "$1" != "test" ]; then show_help exit 1 fi @@ -69,7 +73,7 @@ while [[ $2 ]]; do echo "No resource name provided, exiting..." fi else - echo "No namespace or resource name provided, exiting..." + echo "No resource type or name provided, exiting..." fi break @@ -117,7 +121,7 @@ if ((TEST_BY_NAMESPACE)); then # Test all resources in a given namespace echo "Fetching resources, this may take some time depending on the amount of resources in your cluster..." - get_common_resources < <(kubectl get all -n $NAMESPACE -o name) + get_common_resources < <(kubectl get all -n $NAMESPACE --selector='!pod-template-hash' -o name) get_additional_resources wait