-
-
Save antonioaguilar/f6e89089a32c1662d86540726af37d36 to your computer and use it in GitHub Desktop.
export all VCAP_SERVICES user-provided credentials as individual environment variables for start command shell script (jq 1.3 or newer)
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
#!/bin/bash | |
while read ENV_PAIR; do export "${ENV_PAIR}"; done \ | |
< <(echo $VCAP_SERVICES | jq -r '.["user-provided"] | .[].credentials | to_entries[] | "\(.key)=\(.value)"') | |
# assuming `cf create-user-provider-service foo-service -p '{"MY_VAR":"foo"}'` and bound | |
echo $MY_VAR # => foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment