Skip to content

Instantly share code, notes, and snippets.

@caryyu
Created May 22, 2020 06:02
Show Gist options
  • Save caryyu/fba215a1d1dca8443348c6d9ed6bea31 to your computer and use it in GitHub Desktop.
Save caryyu/fba215a1d1dca8443348c6d9ed6bea31 to your computer and use it in GitHub Desktop.
读取 Vault 密钥到环境变量文件供本地 Docker 调试使用
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