Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antonioaguilar/f6e89089a32c1662d86540726af37d36 to your computer and use it in GitHub Desktop.
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)
#!/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