Skip to content

Commit

Permalink
Merge pull request #399 from hashicorp/aw/setup-envvars
Browse files Browse the repository at this point in the history
Add helper script to setup envvars via envchain
  • Loading branch information
annawinkler committed May 23, 2022
2 parents bf3311c + abf3c3d commit ec7bbc6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/setup-test-envvars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash -e

# setup-test-envvars.sh
#
# A helper script that uses envchain (https://github.com/sorah/envchain) to set environment variables for tests.
# It's required to have TFE_ADDRESS and TFE_TOKEN set, the others are optional.
#
type envchain >/dev/null 2>&1 || { echo >&2 "Required executable 'envchain' not found - install it via 'brew install envchain'. Exiting."; exit 1; }

echo "Set environment variables (envvars) for running tests locally"
echo " envchain will prompt you for values for 4 envvars"
echo " TFE_ADDRESS and TFE_TOKEN are required, the others are optional,"
echo " press 'return' to skip them"
echo ""

read -p "Enter the namespace you want to use in envchain [go-tfe]: " namespace
namespace=${namespace:-go-tfe}
envchain --set ${namespace} TFE_ADDRESS TFE_TOKEN GITHUB_TOKEN GITHUB_POLICY_SET_IDENTIFIER
echo "Done! To see the values: envchain ${namespace} env"

0 comments on commit ec7bbc6

Please sign in to comment.