Skip to content

Commit

Permalink
Make AKS start script more readable (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
adusumillipraveen authored Oct 17, 2023
1 parent fbb7e63 commit 5674426
Showing 1 changed file with 25 additions and 38 deletions.
63 changes: 25 additions & 38 deletions scripts/aks/manual-start.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,30 @@
#!/usr/bin/env bash

# Define an associative array for subscription names, cluster name prefixes
declare -A SUBSCRIPTION_CLUSTERMAP

SUBSCRIPTION_CLUSTERMAP["CFT,Sandbox"]="DCD-CFTAPPS-SBOX,CFT-SBOX"
SUBSCRIPTION_CLUSTERMAP["CFT,AAT / Staging"]="DCD-CFTAPPS-STG,CFT-AAT"
SUBSCRIPTION_CLUSTERMAP["CFT,Test / Perftest"]="DCD-CFTAPPS-TEST,CFT-PERFTEST"
SUBSCRIPTION_CLUSTERMAP["CFT,Preview / Dev"]="DCD-CFTAPPS-DEV,CFT-PREVIEW"
SUBSCRIPTION_CLUSTERMAP["CFT,Demo"]="DCD-CFTAPPS-DEMO,CFT-DEMO"
SUBSCRIPTION_CLUSTERMAP["CFT,ITHC"]="DCD-CFTAPPS-ITHC,CFT-ITHC"
SUBSCRIPTION_CLUSTERMAP["CFT,PTL"]="DTS-CFTPTL-INTSVC,CFT-PTL"
SUBSCRIPTION_CLUSTERMAP["CFT,PTLSBOX"]="DTS-CFTSBOX-INTSVC,CFT-PTLSBOX"

SUBSCRIPTION_CLUSTERMAP["SDS,Sandbox"]="DTS-SHAREDSERVICES-SBOX,SS-SBOX"
SUBSCRIPTION_CLUSTERMAP["SDS,AAT / Staging"]="DTS-SHAREDSERVICES-STG,SS-STG"
SUBSCRIPTION_CLUSTERMAP["SDS,Test / Perftest"]="DTS-SHAREDSERVICES-TEST,SS-TEST"
SUBSCRIPTION_CLUSTERMAP["SDS,Preview / Dev"]="DTS-SHAREDSERVICES-DEV,SS-DEV"
SUBSCRIPTION_CLUSTERMAP["SDS,Demo"]="DTS-SHAREDSERVICES-DEMO,SS-DEMO"
SUBSCRIPTION_CLUSTERMAP["SDS,ITHC"]="DTS-SHAREDSERVICES-ITHC,SS-ITHC"
SUBSCRIPTION_CLUSTERMAP["SDS,PTL"]="DTS-SHAREDSERVICESPTL,SS-PTL"
SUBSCRIPTION_CLUSTERMAP["SDS,PTLSBOX"]="DTS-SHAREDSERVICESPTL-SBOX,SS-PTLSBOX"

function subscription() {
if [[ $SELECTED_ENV =~ "Test / Perftest" && $PROJECT == "SDS" ]]; then
PROJECT="ss"
SELECTED_ENV="test"
SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV"
elif [[ $SELECTED_ENV =~ "Test / Perftest" && $PROJECT == "CFT" ]]; then
SELECTED_ENV="perftest"
SUBSCRIPTION="DCD-CFTAPPS-TEST"
elif [[ $SELECTED_ENV =~ "Preview / Dev" && $PROJECT == "SDS" ]]; then
PROJECT="ss"
SELECTED_ENV="DEV"
SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV"
elif [[ $SELECTED_ENV =~ "Preview / Dev" && $PROJECT == "CFT" ]]; then
SELECTED_ENV="DEV"
SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV"
elif [[ $SELECTED_ENV =~ "AAT / Staging" && $PROJECT == "SDS" ]]; then
PROJECT="ss"
SELECTED_ENV="stg"
SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV"
elif [[ $SELECTED_ENV =~ "AAT / Staging" && $PROJECT == "CFT" ]]; then
SELECTED_ENV="stg"
SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV"
elif [[ $SELECTED_ENV =~ "PTLSBOX" && $PROJECT == "SDS" ]]; then
PROJECT="ss"
SUBSCRIPTION="DTS-SHAREDSERVICESPTL-SBOX"
elif [[ $SELECTED_ENV =~ "PLTSBOX" && $PROJECT == "CFT" ]]; then
SUBSCRIPTION="DTS-CFTSBOX-INTSVC"
elif [[ $SELECTED_ENV =~ "PTL" && $PROJECT == "CFT" ]]; then
SUBSCRIPTION="DTS-CFTPTL-INTSVC"
elif [[ $SELECTED_ENV == "PTL" && $PROJECT == "SDS" ]]; then
PROJECT="ss"
SUBSCRIPTION="DTS-SHAREDSERVICESPTL"
elif [[ $SELECTED_ENV != "Test / Perftest" && $SELECTED_ENV != "Preview / Dev" && $SELECTED_ENV != "AAT / Staging" && $SELECTED_ENV != "PTL" && $SELECTED_ENV != "PLTSBOX" && $PROJECT == "SDS" ]]; then
PROJECT="ss"
SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV"
elif [[ $SELECTED_ENV != "Test / Perftest" && $SELECTED_ENV != "Preview / Dev" && $SELECTED_ENV != "AAT / Staging" && $SELECTED_ENV != "PTL" && $SELECTED_ENV != "PLTSBOX" && $PROJECT == "CFT" ]]; then
SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV"
fi
key="${PROJECT},${SELECTED_ENV}"
SUBSCRIPTION=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 1)
CLUSTER_PREFIX=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 2)

if [[ $INSTANCES == 'All' ]]; then
INSTANCES=(00 01)
Expand All @@ -59,7 +46,7 @@ function ts_echo() {
subscription
for INSTANCE in ${INSTANCES[@]}; do
CLUSTERS=$(az resource list \
--name $PROJECT"-"$SELECTED_ENV"-"$INSTANCE"-aks" \
--name $CLUSTER_PREFIX"-"$INSTANCE"-aks" \
--query "[?tags.autoShutdown == 'true']" -o json)
jq -c '.[]' <<<$CLUSTERS | while read cluster; do
cluster
Expand Down

0 comments on commit 5674426

Please sign in to comment.