Files
threshold/enos/scripts/test_e2e_env.sh
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

40 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Copyright IBM Corp. 2020, 2025
# SPDX-License-Identifier: BUSL-1.1
DIR=$(pwd)
SCRIPTS_DIR=$( cd -- "$( dirname -- "$0" )" &> /dev/null && pwd )
STATEDIR=$(ls -td $SCRIPTS_DIR/../.enos/*/ | head -1) # get latest directory
# Default to linux format
FORMAT="linux"
# Parse flag
while getopts "f:" opt; do
case ${opt} in
f)
if [[ "$OPTARG" == "linux" || "$OPTARG" == "windows" ]]; then
FORMAT="$OPTARG"
else
echo "Invalid format. Use 'linux' or 'windows'."
exit 1
fi
;;
*)
echo "Usage: $0 [-f linux|windows]"
exit 1
;;
esac
done
cd $STATEDIR
if [[ "$FORMAT" == "windows" ]]; then
terraform show -json terraform.tfstate | jq -r '.values.root_module.child_modules[].resources[] | select(.address=="module.run_e2e_test.enos_local_exec.run_e2e_test") | .values.environment | to_entries[] | select(.value != "") | "$env:\(.key)=\(.value|@sh);"'
else
terraform show -json terraform.tfstate | jq -r '.values.root_module.child_modules[].resources[] | select(.address=="module.run_e2e_test.enos_local_exec.run_e2e_test") | .values.environment | to_entries[] | select(.value != "") | "export \(.key)=\(.value|@sh);"'
fi
cd $DIR