Node.js library for interfacing with the Cloud Foundry command line interface (cf
).
cf
must be installed and configured on the system for this module to work. Refer to https://docs.cloudfoundry.org/cf-cli/install-go-cli.html for installation on the system of your interest.
If you don't want to install cf
, you can use a module like cf-nodejs-client.
The advantage of cloudfoundry-cli
over cf-nodejs-client
is that, cloudfoundry-cli
does not need to know any authentication
details, since it relies on the underlying cf
for it.
Listing services:
const cf = require('cloudfoundry-cli')
var services = cf.getServicesSync()
console.log(services) // list of provisioned services
Provisioning a service:
const cf = require('cloudfoundry-cli')
cf.provisionService({
name: 'mongoNo1',
type: 'compose-for-mongodb',
plan: 'Standard'
}, function(err) {
if (err) return console.log(err)
console.log('Service provisioned')
})
NOTE: Complete interface support to cf
is still a work in progress, only completed interfaces are documented.
const cf = require('cloudfoundry-cli');
All further code samples will refer to the variable cf
instantiated above.
filters
is defined in the querystring format.
cf.getApps(function(err, apps) {
if (err) return console.log(err)
console.log(apps)
})
var apps = cf.getAppsSync()
console.log(apps)
cf.getApps(function(err, services) {
if (err) return console.log(err)
console.log(services)
})
var services = cf.getServicesSync([filters])
console.log(services)
details
object can have the following following properties:
name
: Name of the servicetype
: Service typeplan
: Plan type of the service
cf.createService({
name: 'mongoNo1',
type: 'compose-for-mongodb',
plan: 'Standard'
}, function(err) {
if (err) return console.log(err, service)
console.log('Service provisioned')
console.log(service)
})
details
object can have the following following properties:
name
: Name of the servicetype
: Service typeplan
: Plan type of the service
var service = cf.provisionService({
name: 'mongoNo1',
type: 'compose-for-mongodb',
plan: 'Standard'
})
console.log(service)
name
: Name of the servicecallback
: Callback function
name
: Name of the service