From f010b9fbda88f1c4be996fee7c1858504fdd7962 Mon Sep 17 00:00:00 2001 From: Diego Casati Date: Tue, 25 Oct 2022 13:12:27 -0600 Subject: [PATCH] add a util to check deps. fail if vars are not set --- start.sh | 6 ++++++ utils.sh | 24 ++++++++++++++++++++++++ walk-the-dog.sh | 13 +++++-------- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 utils.sh diff --git a/start.sh b/start.sh index 473cc25..2804546 100755 --- a/start.sh +++ b/start.sh @@ -1,3 +1,9 @@ +#!/usr/bin/env bash +set -eou pipefail + +source utils.sh + +check_dependencies mkdir -p outputs # get params from config.json file diff --git a/utils.sh b/utils.sh new file mode 100644 index 0000000..3b2044a --- /dev/null +++ b/utils.sh @@ -0,0 +1,24 @@ +check_dependencies() { + local _DEP_FLAG _NEEDED + + # check if the dependencies are installed + _NEEDED="az jq" + _DEP_FLAG=false + + echo -e "Checking dependencies for the creation of the branches ...\n" + for i in ${_NEEDED} + do + if hash "$i" 2>/dev/null; then + # do nothing + : + else + echo -e "\t $_ not installed". + _DEP_FLAG=true + fi + done + + if [[ "${_DEP_FLAG}" == "true" ]]; then + echo -e "\nDependencies missing. Please fix that before proceeding" + exit 1 + fi +} \ No newline at end of file diff --git a/walk-the-dog.sh b/walk-the-dog.sh index d2f4732..80dafa6 100755 --- a/walk-the-dog.sh +++ b/walk-the-dog.sh @@ -1,3 +1,7 @@ +#!/usr/bin/env bash + +set -eou pipefail + mkdir -p outputs export RG_NAME=$1 export LOCATION=$2 @@ -189,14 +193,7 @@ az ad sp create-for-rbac \ --cert $RG_NAME-cert \ --keyvault $KV_NAME \ --years 1 - -az ad sp create-for-rbac \ - --name "http://sp-briantest.microsoft.com" \ - --only-show-errors \ - --create-cert \ - --cert reddog-aks-4475-test-cert \ - --keyvault reddog358briar4475 \ - --years 1 + ## Get SP APP ID echo 'Getting SP_APPID ...'