diff options
-rwxr-xr-x | build/creating_data/docker-images-collector.sh | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/build/creating_data/docker-images-collector.sh b/build/creating_data/docker-images-collector.sh index e33d5003..49d45bef 100755 --- a/build/creating_data/docker-images-collector.sh +++ b/build/creating_data/docker-images-collector.sh @@ -35,6 +35,7 @@ usage () { echo " Options:" echo " -h | --help Show script usage synopsis" echo " -p | --helm-port Chart repository server port" + echo " -b | --helm-bin Path to Helm executable" echo " " echo " Example: ./$(basename $0) /root/oom/kubernetes/onap" echo " " @@ -64,14 +65,14 @@ create_list() { else >&2 echo -e \n" !!! ${1} sybsystem does not exist !!!"\n fi - helm template --set global.masterPassword=TemplatePassword,global.offlineDeploymentBuild=true -f ${PROJECT_DIR}/values.yaml "${SUBSYS_DIR}" | grep 'image:\ \|tag_version:\ \|h._image' | + ${HELM_BIN} template --set global.masterPassword=TemplatePassword,global.offlineDeploymentBuild=true -f ${PROJECT_DIR}/values.yaml "${SUBSYS_DIR}" | grep 'image:\ \|tag_version:\ \|h._image' | sed -e 's/^.*\"h._image\"\ :\ //; s/^.*\"\(.*\)\".*$/\1/' \ -e 's/\x27\|,//g; s/^.*\(image\|tag_version\):\ //' | tr -d '\r' } # Kill helm if already running kill_helm() { - for pid in $(pgrep -f "helm serve --address ${HELM_REPO}"); + for pid in $(pgrep -f "${HELM_BIN} serve --address ${HELM_REPO}"); do kill $pid done @@ -90,9 +91,23 @@ validate_port() { fi } +validate_bin() { + if [ -z $1 ]; + then + echo "Error: No path to executable provided" + exit 1 + else + if ! [[ -x ${1} && -f ${1} ]]; + then + echo "Error: ${1} is not an executable" + exit 1 + fi + fi +} + check_helm() { sleep 2 # let the helm process settle - if [ $(pgrep -f "helm serve --address ${HELM_REPO}" -c) -eq 0 ]; + if [ $(pgrep -f "${HELM_BIN} serve --address ${HELM_REPO}" -c) -eq 0 ]; then echo "Fatal: Helm chart repository server failed to start" exit 1 @@ -115,6 +130,11 @@ do validate_port "${PORT}" shift 2 ;; + -b | --helm-bin) + BIN="${2}" + validate_bin "${BIN}" + shift 2 + ;; -*) echo "Unknown option ${1}" usage @@ -130,6 +150,7 @@ done PROJECT_DIR="${1}" LIST="${2}" LISTS_DIR="$(readlink -f $(dirname ${0}))/../data_lists" +HELM_BIN=${BIN:-helm} HELM_REPO_HOST="127.0.0.1" HELM_REPO_PORT="${PORT:-8879}" HELM_REPO="${HELM_REPO_HOST}:${HELM_REPO_PORT}" @@ -160,9 +181,9 @@ HELM_HOME=$(mktemp -p /tmp -d .helm.XXXXXXXX) export HELM_HOME kill_helm # make sure it's not already running mkdir -p "${PROJECT_DIR}/../${HELM_REPO_PATH}" -helm init --skip-refresh -c --local-repo-url "http://${HELM_REPO}" -helm serve --address ${HELM_REPO} --repo-path "${PROJECT_DIR}/../${HELM_REPO_PATH}" & -helm repo remove stable 2>/dev/null || true +${HELM_BIN} init --skip-refresh -c --local-repo-url "http://${HELM_REPO}" +${HELM_BIN} serve --address ${HELM_REPO} --repo-path "${PROJECT_DIR}/../${HELM_REPO_PATH}" & +${HELM_BIN} repo remove stable 2>/dev/null || true check_helm # Make all @@ -170,6 +191,7 @@ pushd "${PROJECT_DIR}/.." echo "Building project..." export SKIP_LINT=TRUE export DOCKER_CONTAINER +export HELM_BIN make -e all > /dev/null; make -e ${PROJECT} > /dev/null popd |