Skip to content

Commit

Permalink
cleanup script output
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Way committed Feb 2, 2023
1 parent 8118c07 commit a15cb30
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions importVariables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ else
touch $TFVAR_FILENAME
fi

echo ${#KEYS[@]}
# echo ${#KEYS[@]} # length of array

for ((i = 0; i < LENGTH; i++)); do
echo ${KEYS[i]}:${VALUES[i]}

if [[ ${VALUES[i]} =~ ^(\"\$\{env0:) ]]; then
echo ${KEYS[i]}:${VALUES[i]}
# split the string across ':'
SPLIT_VALUES=($(echo ${VALUES[i]} | tr ":" "\n"))
SOURCE_ENV0_ENVIRONMENT_ID=${SPLIT_VALUES[1]}
len=$((${#SPLIT_VALUES[2]}-2))
SOURCE_OUTPUT_NAME=${SPLIT_VALUES[2]:0:$len}
echo "need to fetch value for ${KEYS[i]}:$SOURCE_OUTPUT_NAME from ${SOURCE_ENV0_ENVIRONMENT_ID}"

echo "fetch value for ${KEYS[i]}:$SOURCE_OUTPUT_NAME from ${SOURCE_ENV0_ENVIRONMENT_ID}"

# fetch logs from environment
curl -s --request GET \
Expand All @@ -50,8 +48,8 @@ for ((i = 0; i < LENGTH; i++)); do

# store value in .auto.tfvars
echo "${KEYS[i]}=$SOURCE_OUTPUT_VALUE" >> $TFVAR_FILENAME

# show updated values
cat $TFVAR_FILENAME
fi
done

# show updated values
cat $TFVAR_FILENAME

0 comments on commit a15cb30

Please sign in to comment.