Whenever a variable has the value <VAULT>, auto-fetch value from vault.

This commit is contained in:
Martin Lablans
2022-05-12 18:23:52 +02:00
parent 2b4ea24b59
commit d428f08d8a
2 changed files with 19 additions and 0 deletions

View File

@ -23,3 +23,21 @@ checkRequirements() {
return 0
fi
}
fetchVarsFromVault() {
VARS_TO_FETCH=""
for line in $(cat $@); do
if [[ $line =~ .*=\<VAULT\>.* ]]; then
VARS_TO_FETCH+="$(echo -n $line | sed 's/=.*//') "
fi
done
if [ -z "$VARS_TO_FETCH" ]; then
return 0
fi
eval $(docker run --rm -ti -e BW_MASTERPASS -e BW_CLIENTID -e BW_CLIENTSECRET bwcli $VARS_TO_FETCH | sed 's/\r//g')
return 0
}