Skip to content

Commit

Permalink
script file modified in order to be executable using cygwin
Browse files Browse the repository at this point in the history
  • Loading branch information
anttorre committed Oct 15, 2021
1 parent 55d1b14 commit 3519655
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/k8s/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ aks_name=$(az aks list -o tsv --query "[?contains(name,'aks')].{Name:name}")
aks_resource_group_name=$(az aks list -o tsv --query "[?contains(name,'aks')].{Name:resourceGroup}")
aks_private_fqdn=$(az aks list -o tsv --query "[?contains(name,'aks')].{Name:privateFqdn}")

# in widows, even if using cygwin, these variables will contain a landing \r character
aks_name=${aks_name//[$'\r']}
aks_resource_group_name=${aks_resource_group_name//[$'\r']}
aks_private_fqdn=${aks_private_fqdn//[$'\r']}

# if using cygwin, we have to transcode the WORKDIR
HOME_DIR=$HOME
if [[ $HOME_DIR == /cygdrive/* ]]; then
HOME_DIR=$(cygpath -w ~)
fi

rm -rf "${HOME}/.kube/config-${aks_name}"
az aks get-credentials -g "${aks_resource_group_name}" -n "${aks_name}" --subscription "${SUBSCRIPTION}" --file "~/.kube/config-${aks_name}"
az aks get-credentials -g "${aks_resource_group_name}" -n "${aks_name}" --subscription "${SUBSCRIPTION}" --overwrite-existing
Expand All @@ -41,6 +52,6 @@ echo "kube_config_path=~/.kube/config-${aks_name}" >> "${WORKDIR}/subscriptions/

# with AAD auth enabled we need to authenticate the machine on the first setup
echo "Follow Microsoft sign in steps. kubectl get pods command will fail but it's the expected behavior"
kubectl --kubeconfig="${HOME}/.kube/config-${aks_name}" get pods
kubectl --kubeconfig="${HOME_DIR}/.kube/config-${aks_name}" get pods
kubectl config use-context "${aks_name}"
kubectl get pods
6 changes: 6 additions & 0 deletions src/k8s/terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ terraform init -reconfigure \
-backend-config="storage_account_name=${storage_account_name}" \
-backend-config="resource_group_name=${resource_group_name}"

# if using cygwin, we have to transcode the WORKDIR
if [[ $WORKDIR == /cygdrive/* ]]; then
WORKDIR=$(cygpath -w $WORKDIR)
fi


export HELM_DEBUG=1
if echo "plan apply refresh import output destroy" | grep -w ${COMMAND} > /dev/null; then
if [ ${COMMAND} = "output" ]; then
Expand Down

0 comments on commit 3519655

Please sign in to comment.