ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
#Check for helm3
-IS_HELM3=$(helm version --short|grep -e "^v3")
+IS_HELM3=$(helm version -c --short|grep -e "^v3")
# Start Helm local repo if there isn't one
HELM_REPO_PID=$(ps -x | grep "helm serve" | grep -v "grep" | awk '{print $1}')
fi
fi
+# Check if servecm plugin is ready to serve request
+command='curl --silent --output /dev/null http://127.0.0.1:8879/charts'
+for i in $(seq 1 5)
+do $command && s=0 && break || s=$? && echo "Error connecting chartmuseum server. Retrying after 5s" && sleep 5;
+done
+
+if [ $s -gt 0 ]
+then
+ echo "Cmd to test chartmuseum failed with ($s): $command"
+ exit $s
+fi
+
# Package common templates and serve it using Helm local repo
if [ $IS_HELM3 ]
then