From 06d7d7e2f4abbc299ed8aca7bbfcc091ac7c90e0 Mon Sep 17 00:00:00 2001 From: Alexander Twrdik <6052859+DiCanio@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:46:07 +0100 Subject: [PATCH] fix: fixup --- k8s/deploy-to-minikube.sh | 72 ++++++++++----------------------------- 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/k8s/deploy-to-minikube.sh b/k8s/deploy-to-minikube.sh index e7da0a1..fdc4bc3 100755 --- a/k8s/deploy-to-minikube.sh +++ b/k8s/deploy-to-minikube.sh @@ -27,25 +27,24 @@ if [[ -z "${AUTH_JWKS_URL}" || -z "${HUB_AUTH_ROBOT_ID}" || -z "${ROBOT_SECRET}" exit 1 fi +checkSuccessOrFailWithCode() { + if [ $1 -ne 0 ]; then + echo "FAILED" + exit $2 + else + echo "OK" + fi +} + echo -n "Creating temporary working directory..." WORK_DIR=`mktemp -d -p "${BASE_DIR}"` -if [ $? -ne 0 ]; then - echo "FAILED" - exit 2 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 2 echo -n "Copying k8s manifest files..." for f in "${BASE_DIR}"/manifests/*.yml; do cp "${f}" "${WORK_DIR}" done -if [ $? -ne 0 ]; then - echo "FAILED" - exit 3 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 3 echo -n "Preparing broker deployment..." sed -i -e "s##${AUTH_JWKS_URL}#" \ @@ -53,51 +52,26 @@ sed -i -e "s##${AUTH_JWKS_URL}#" \ -e "s##${HUB_AUTH_BASE_URL:-"https://auth.privateaim.net"}#" \ -e "s##${HUB_BASE_URL:-"https://api.privateaim.net"}#" \ "${WORK_DIR}/broker-deployment.yml" -if [ $? -ne 0 ]; then - echo "FAILED" - exit 4 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 4 echo -n "Preparing hub auth secret..." sed -i -e "s##$(echo -n ${ROBOT_SECRET} | base64)#" \ "${WORK_DIR}/hub-auth-secret.yml" -if [ $? -ne 0 ]; then - echo "FAILED" - exit 5 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 5 echo -n "Preparing ingress..." sed -i -e "s##${NODE_MESSAGE_BROKER_HOST}#" \ "${WORK_DIR}/ingress.yml" -if [ $? -ne 0 ]; then - echo "FAILED" - exit 6 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 6 echo -n "Deleting previous image..." minikube image rm docker.io/flame/node-message-broker:latest >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "FAILED" - exit 7 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 7 echo -n "Creating Docker image..." minikube image build -t docker.io/flame/node-message-broker:latest "${BASE_DIR}/.." >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "FAILED" - exit 8 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 8 echo -n "Applying manifest files..." # TODO: make namespace adjustable!!! @@ -107,18 +81,8 @@ minikube kubectl -- --namespace "${NAMESPACE}" apply -f "${WORK_DIR}/hub-auth-se -f "${WORK_DIR}/broker-service.yml" \ -f "${WORK_DIR}/broker-deployment.yml" \ -f "${WORK_DIR}/ingress.yml" >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "FAILED" - exit 9 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 9 echo -n "Deleting temporary working directory..." rm -Rf "${WORK_DIR}" -if [ $? -ne 0 ]; then - echo "FAILED" - exit 10 -else - echo "OK" -fi +checkSuccessOrFailWithCode $? 10