push2cloud-cf-adapter
This repository is part of the push2cloud project. For contribution guidelines, issues, and general documentation, visit the main push2cloud project page.
push2cloud-cf-adapter abstracts the cloud foundry api.
It's designed for use with Node.js and installable via npm install --save push2cloud-cf-adapter
.
Usage
const cf = require('push2cloud-cf-adapter');
const api = cf({
api: process.env.CF_API || 'https://api.lyra-836.appcloud.swisscom.com',
username: process.env.CF_USER,
password: process.env.CF_PWD,
org: process.env.CF_ORG,
space: process.env.CF_SPACE
});
api.init((err, result) => {
api.pushApp({
name: 'temp-app',
appPath: join(__dirname, '/sampleApp')
}, (err, app) => {
api.stageApp({
appGuid: app.metadata.guid
}, (err) => {
api.startAppAndWaitForInstances({
appGuid: app.metadata.guid
}, (err) => {
});
});
});
});
api.init()
.then((app) => {
return api.stageApp({
appGuid: app.metadata.guid
});
})
.then(() => {
return api.startAppAndWaitForInstances({
appGuid: app.metadata.guid
});
})
.then(() => {
});
Download
The source is available for download from
GitHub.
Alternatively, you can install using npm:
npm install --save push2cloud-cf-adapter
You can then require()
push2cloud-cf-adapter as normal:
const cf = require('push2cloud-cf-adapter');
Documentation
Each asynchronous call can be done with classical callback style or with promise style.
init([callback])
Retrieves information of the current space. i.e. apps, services, service bindings, routes, domains, etc...
Arguments
none
Examples
const cf = require('push2cloud-cf-adapter');
const api = cf({
api: 'https://the-url-to-the-cloud-foundry-api-endpoint',
username: 'my-funny-username',
password: 'my-very-secret-password',
org: 'the-cf-org',
space: 'the-cf-space'
});
api.init((err, result) => {
console.log(result);
});
getInfo([callback])
Retrieves information of the cloud foundry platform.
Arguments
none
Example
api.getInfo((err, result) => {
console.log(result);
});