Skip to content

Commit

Permalink
move conversion of azure_env to arm_env to script and source it
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvalyaron committed Mar 27, 2023
1 parent 6985725 commit 21d96d9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/actions/devcontainer_run_command/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ runs:
- name: Construct ARM_ENVIRONMENT
shell: bash
run: |
declare -A arm_envs=( ["AzureCloud"]="public" ["AzureUSGovernment"]="usgovernment")
azure_env="${{ env.AZURE_ENVIRONMENT }}"
echo "ARM_ENVIRONMENT=${arm_envs[${azure_env}]}" >> $GITHUB_ENV
source devops/scripts/convert_azure_env_to_arm_env.sh
arm_environment=$(convert_azure_env_to_arm_env "${{ env.AZURE_ENVIRONMENT }}")
echo "ARM_ENVIRONMENT=$arm_environment" >> $GITHUB_ENV
- name: Construct ACR Domain Suffix
shell: bash
Expand Down
1 change: 0 additions & 1 deletion devops/scripts/construct_tre_url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set -o nounset

# This script is designed to be `source`d to create reusable helper functions

# This script
function construct_tre_url()
{
tre_id=$1
Expand Down
13 changes: 13 additions & 0 deletions devops/scripts/convert_azure_env_to_arm_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset

# This script is designed to be `source`d to create reusable helper functions

function convert_azure_env_to_arm_env()
{
azure_environment=$1
declare -A arm_envs=( ["AzureCloud"]="public" ["AzureUSGovernment"]="usgovernment")
echo "${arm_envs[${azure_environment}]}"
}
9 changes: 5 additions & 4 deletions devops/scripts/load_and_validate_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ set -o nounset

# shellcheck disable=SC1091
source "${DIR}"/construct_tre_url.sh
# shellcheck disable=SC1091
source "${DIR}"/convert_azure_env_to_arm_env.sh

if [ ! -f "config.yaml" ]; then
if [ -z "${USE_ENV_VARS_NOT_FILES:-}" ]; then
Expand Down Expand Up @@ -50,11 +52,10 @@ else
AZURE_ENVIRONMENT=$(az cloud show --query name --output tsv)
export AZURE_ENVIRONMENT

declare -A arm_environments=( ["AzureCloud"]="public" ["AzureUSGovernment"]="usgovernment")

# The ARM Environment is required by terrafform to indicate the destination cloud.
export ARM_ENVIRONMENT="${arm_environments[${AZURE_ENVIRONMENT}]}"
export TF_VAR_arm_environment="${arm_environments[${AZURE_ENVIRONMENT}]}"
ARM_ENVIRONMENT=$(convert_azure_env_to_arm_env "${AZURE_ENVIRONMENT}")
export ARM_ENVIRONMENT
export TF_VAR_arm_environment="${ARM_ENVIRONMENT}"

TRE_URL=$(construct_tre_url "${TRE_ID}" "${LOCATION}" "${AZURE_ENVIRONMENT}")
export TRE_URL
Expand Down

0 comments on commit 21d96d9

Please sign in to comment.