Created
April 28, 2020 19:45
-
-
Save alagalah/da14348150af0195a93f0ab82c442170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create the Environment variables needed during Bifocals iteration | |
# Login to 1P(assword) | |
eval $(op signin my) | |
# Fetch the env-vars from 1P | |
ev=`op get item "bifocals"` | |
# Convert to base64 for multi-line secrets. | |
# t as the label, and v as the value. | |
for row in $(echo ${ev} | jq -r -c '.details.sections[0].fields[] | @base64'); do | |
_envvars() { | |
echo ${row} | base64 --decode | jq -r ${1} | |
} | |
ENV_NAME=$(_envvars '.t') | |
BAD_PART=" (using streamsets-ci)" | |
ENV_NAME=${ENV_NAME//$BAD_PART/} # One name has the BAD_PART, can't be used as is. | |
ENV_VALUE=$(_envvars '.v') | |
ENV_VALUE="'${ENV_VALUE}'" # Surrounding with quotes for /n is ignored | |
declare ${ENV_NAME}=${ENV_VALUE} | |
echo "Exporting ${ENV_NAME}" | |
export "${ENV_NAME}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment