Created
May 22, 2020 06:02
-
-
Save caryyu/fba215a1d1dca8443348c6d9ed6bea31 to your computer and use it in GitHub Desktop.
读取 Vault 密钥到环境变量文件供本地 Docker 调试使用
This file contains hidden or 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
export VAULT_ADDR=https://xxx | |
export VAULT_TOKEN=xxx | |
export VAULT_PATH="secret/projects/xxxxxx/services/org-global/defaults" | |
rm -f ~/.we/org-global | |
OUTPUT=`vault list -format=json $VAULT_PATH | jq -c '.[]' | grep -v "env-file" | sed 's/"//g' | awk '{ print "vault kv get -format=json '$VAULT_PATH'/"$1" | jq .data.value | sed '"'"'s/\"//g'"'"' | awk '"'"'{print \""$1"=\"\$1}'"'"' >> ~/.we/org-global"}'` | |
eval $OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment