ibm-cloud-env module allows to abstract environment variables from various Cloud compute providers, such as, but not limited to, CloudFoundry and Kubernetes, so the application could be environment-agnostic.
The module allows to define an array of search patterns that will be executed one by one until required value is found.
npm install ibm-cloud-env
Create a JSON file containing your mappings and initialize the module
const IBMCloudEnv = ;IBMCloudEnv;
In case mappings file path is not specified in the
IBMCloudEnv.init() the module will try to load mappings from a default path of
ibm-cloud-config supports searching for values using three search pattern types - cloudfoundry, env, file.
cloudfoundryallows to search for values in VCAP_SERVICES and VCAP_APPLICATIONS environment variables
envallows to search for values in environment variables
fileallows to search for values in text/json files
credentialsobject of the matching service instance name
In your application retrieve the values using below commands
var service1credentials = IBMCloudEnv; // this will be a dictionaryvar service2username = IBMCloudEnv; // this will be a string
Following the above approach your application can be implemented in an runtime-environment agnostic way, abstracting differences in environment variable management introduced by different cloud compute providers.
In order to publish changes, you will need to fork the repository or ask to join the
ibm-developer org and branch off the
Make sure to follow the conventional commit specification before contributing. To help you with commit a commit template is provide. Run
config.sh to initialize the commit template to your
.git/config or use commitizen
Once you are finished with your changes, run
npm test to make sure all tests pass.
Do a pull request against
master, make sure the build passes. A team member will review and merge your pull request.
Once merged to
master an auto generated pull request will be created against master to update the changelog. Make sure that the CHANGELOG.md and the package.json is correct before merging the pull request. After the auto generated pull request has been merged to
master the version will be bumped and published to npm.