Skip to content

Latest commit

 

History

History
executable file
·
101 lines (81 loc) · 2.98 KB

README.md

File metadata and controls

executable file
·
101 lines (81 loc) · 2.98 KB

VCAP_SERVICES

Build Status Coverage Status npm-version npm-downloads

Parse and return service credentials from VCAP_SERVICES environment variable that Bluemix provides.

Installation

$ npm install vcap_services --save

Usage

var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'personality_insights' });
console.log(credentials);

If VCAP_SERVICES is:

{
  "personality_insights": [{
      "credentials": {
        "password": "<password>",
        "url": "<url>",
        "username": "<username>"
      },
    "label": "personality_insights",
    "name": "personality-insights-service",
    "plan": "standard"
  }]
}

Output:

{
  "password": "<password>",
  "url": "<url>",
  "username": "<username>"
}

Getting credentials for a specific plan

Get credentials that match a specific service plan (only for VCAP_SERVICES).

var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'personality_insights', instance: { plan: 'standard' } });
console.log(credentials);

Getting credentials for a specific instance

Get credentials that match a specific service instance (replace "YOUR NLC NAME" with the name of your service instance).

var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'natural_language_classifier', { instance: { name: 'YOUR NLC NAME' } });
console.log(credentials);

Getting credentials for a specific plan and instance

Get credentials that match a specific service plan and instance (replace "YOUR NLC NAME" with the name of your service instance).

var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ service: 'natural_language_classifier', instance: { plan: 'standard', name: 'YOUR NLC NAME' } });
console.log(credentials);

Getting credentials for a specific tag

Get credentials that match a specific service tag, regardless of the service type.

var vcapServices = require('vcap_services');
var credentials = vcapServices.findCredentials({ instance: { tags: 'object-storage' } });
console.log(credentials);

Tests

Running all the tests:

$ npm test

Running a specific test:

$ mocha -g '<test name>'

License

MIT.

Contributing

See CONTRIBUTING.