Skip to content

Instantly share code, notes, and snippets.

@micahyoung
Last active March 7, 2019 11:22
Show Gist options
  • Save micahyoung/0c1302606f466bd83cb5a31f3d0ee215 to your computer and use it in GitHub Desktop.
Save micahyoung/0c1302606f466bd83cb5a31f3d0ee215 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