Allows for customised flattening of env vars in Cloud Foundry VCAP_SERVICES
based on jq
selectors. Requires a stack with jq
already installed.
NB: This is intended only for situations where high levels of customisation are needed e.g. 3rd party software. For most situations, the pancake-buildpack is likely a better option.
When using Cloud Foundry, services such as databases are provided by service bindings using the Open Service Broker API. The credentials, URLs etc. of these services are placed into a JSON formatted environment variable called VCAP_SERVICES
. To consume these credentials applications typically either include code to parse the JSON or use custom entry scripts.
This buildpack utilizes the profile.d
directory to supply a script that will export environment variables based on a selectors using the popular jq
binary. Any scripts present in the profile.d
directory will be source
d when the application starts up.
To use this buildpack, include https://github.com/andy-paine/env-map-buildpack anywhere but the last element in the buildpacks
field in your Cloud Foundry manifest:
buildpacks:
- https://github.com/andy-paine/env-map-buildpack
- python_buildpack
Include an env-map.yml
file in the directory which you cf push
- see examples directory for full details.
Any selector which works when performing echo "$VCAP_SERVICES" | jq '<selector>'
will work with this buildpack.
This buildpack does not attempt to resolve situations such as multiple results returned by selector or invalid selectors.
To use an alternative file name/location, set
ENV_MAP_BP_CONFIG
to the path of your config file relative to the root of the app which is pushed
To make configuration easier, YAML is the default configuration format. To parse this format, the buildpack downloads and uses yq. For users who cannot download external binaries or for users who prefer JSON for configuration, you can provide a mapping file in JSON format with a .json
extension. This will skip downloading yq
and so should work on security concious/air-gapped environments.
To instruct the buildpack to use a JSON formatted file, use the ENV_MAP_BP_CONFIG
environment variable detailed above.