@@ -18,6 +18,8 @@ set -o nounset # exit when script tries to use undeclared variables.
1818set  -o pipefail #  make the pipeline fail if any command in it fails.
1919
2020REPO_ROOT=$( dirname " ${BASH_SOURCE[0]} " ) 
21+ #  shellcheck source=hack/common-vars.sh
22+ source  " ${REPO_ROOT} /hack/common-vars.sh" 
2123#  shellcheck source=hack/ensure-azcli.sh
2224source  " ${REPO_ROOT} /hack/ensure-azcli.sh" #  install az cli and login using WI
2325#  shellcheck source=hack/ensure-tags.sh
@@ -177,6 +179,28 @@ create_aks_cluster() {
177179}
178180
179181set_env_varaibles (){
182+ rm aks-mgmt-vars.env ||  true 
183+ cat << EOF  > aks-mgmt-vars.env
184+ export MGMT_CLUSTER_NAME="${MGMT_CLUSTER_NAME} " 
185+ export AKS_RESOURCE_GROUP="${AKS_RESOURCE_GROUP} " 
186+ export AKS_NODE_RESOURCE_GROUP="${AKS_NODE_RESOURCE_GROUP} " 
187+ export MGMT_CLUSTER_KUBECONFIG="${MGMT_CLUSTER_KUBECONFIG} " 
188+ export AKS_MI_CLIENT_ID="${AKS_MI_CLIENT_ID} " 
189+ export AZURE_CLIENT_ID="${AKS_MI_CLIENT_ID} " 
190+ export AKS_MI_OBJECT_ID="${AKS_MI_OBJECT_ID} " 
191+ export AKS_MI_RESOURCE_ID="${AKS_MI_RESOURCE_ID} " 
192+ export MANAGED_IDENTITY_NAME="${MANAGED_IDENTITY_NAME} " 
193+ export MANAGED_IDENTITY_RG="${MANAGED_IDENTITY_RG} " 
194+ export AZURE_CLIENT_ID_USER_ASSIGNED_IDENTITY="${AKS_MI_CLIENT_ID} " 
195+ export CI_RG="${MANAGED_IDENTITY_RG} " 
196+ export USER_IDENTITY="${MANAGED_IDENTITY_NAME} " 
197+ export CLUSTER_IDENTITY_TYPE="UserAssignedMSI" 
198+ export ASO_CREDENTIAL_SECRET_MODE="${ASO_CREDENTIAL_SECRET_MODE} " 
199+ export REGISTRY="${REGISTRY} " 
200+ export APISERVER_LB_DNS_SUFFIX="${APISERVER_LB_DNS_SUFFIX} " 
201+ export AZURE_LOCATION="${AZURE_LOCATION} " 
202+ EOF 
203+ 
180204  cat << EOF  > tilt-settings-temp.yaml
181205kustomize_substitutions: 
182206  MGMT_CLUSTER_NAME: "${MGMT_CLUSTER_NAME} " 
@@ -210,28 +234,28 @@ else
210234fi 
211235
212236#  copy over the existing allowed_contexts to tilt-settings.yaml if it does not exist
213- allowed_contexts_exists=$( yq  eval  ' .allowed_contexts' ) 
237+ allowed_contexts_exists=$( ${YQ}  eval  ' .allowed_contexts' ) 
214238if  [ " $allowed_contexts_exists " ==  " null" ;  then 
215-   yq  eval  ' .allowed_contexts = load("tilt-settings-temp.yaml") | .allowed_contexts' >  tilt-settings.yaml
239+   ${YQ}  eval  ' .allowed_contexts = load("tilt-settings-temp.yaml") | .allowed_contexts' >  tilt-settings.yaml
216240fi 
217241
218242#  extract allowed_contexts from tilt-settings.yaml
219- current_contexts=$( yq  eval  ' .allowed_contexts' |  sort -u) 
243+ current_contexts=$( ${YQ}  eval  ' .allowed_contexts' |  sort -u) 
220244
221245#  extract allowed_contexts from tilt-settings-new.yaml
222- new_contexts=$( yq  eval  ' .allowed_contexts' |  sort -u) 
246+ new_contexts=$( ${YQ}  eval  ' .allowed_contexts' |  sort -u) 
223247
224248#  combine current and new contexts, keeping the union of both
225249combined_contexts=$( echo " $current_contexts " $' \n ' " $new_contexts " |  sort -u) 
226250
227- #  create a temporary file since env($combined_contexts) is not supported in yq 
251+ #  create a temporary file since env($combined_contexts) is not supported in ${YQ} 
228252echo  " $combined_contexts " >  combined_contexts.yaml
229253
230254#  update allowed_contexts in tilt-settings.yaml with the combined contexts
231- yq  eval  --inplace " .allowed_contexts = load(\" combined_contexts.yaml\" )" 
255+ ${YQ}  eval  --inplace " .allowed_contexts = load(\" combined_contexts.yaml\" )" 
232256
233257#  merge the updated kustomize_substitution and azure_location with the existing one in tilt-settings.yaml
234- yq  eval-all ' select(fileIndex == 0) *+ {"kustomize_substitutions": select(fileIndex == 1).kustomize_substitutions, "azure_location": select(fileIndex == 1).azure_location}' >  tilt-settings-new.yaml
258+ ${YQ}  eval-all ' select(fileIndex == 0) *+ {"kustomize_substitutions": select(fileIndex == 1).kustomize_substitutions, "azure_location": select(fileIndex == 1).azure_location}' >  tilt-settings-new.yaml
235259
236260mv tilt-settings-new.yaml tilt-settings.yaml
237261rm -r combined_contexts.yaml
0 commit comments