Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Update env, mbaas cmds to reflect new mongoose models. Add docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cianclarke committed Oct 21, 2014
1 parent 14f87f1 commit fe5b762
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 25 deletions.
10 changes: 10 additions & 0 deletions doc/admin-environments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fhc admin-environments [list]
fhc admin-environments read --id=<environment id>
fhc admin-environments create --id=<environment id> --label=<label> --targets=<mbaasTargetId1>,<mbaasTargetId2> [--autoDeployOnCreate=<true|false>] [--autoDeployOnUpdate=<true|false>]
fhc admin-environments update --id=<environment id> [--label=<label>] [--targets=<target1>,<target2>] [--autoDeployOnCreate=<true|false>] [--autoDeployOnUpdate=<true|false>]
fhc admin-environments delete --id=<environment id>

Where:
`targets` is a comma separated list of mBaaS hostnames which this environment should deploy to. In most cases, this will be a single mBaaS. To see a list of available mBaaS targets, use the `fhc admin-mbaas` command.
`autoDeployOnCreate` automatically deploys cloud apps to this environment upon first creation. This should be typically set to true for the first environment in your lifecycle chain (often `dev`), so that your new app is immediately previewable.
`autoDeployOnUpdate` automatically deploys cloud apps to this environment for all subsequent updates.
10 changes: 10 additions & 0 deletions doc/admin-mbaas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fhc admin-mbaas [list]
fhc admin-mbaas read --id=<mBaaS id>
fhc admin-mbaas create --id=<mBaaS id> --url=<mBaaS URL> --servicekey=<mBaaS Service Key>
fhc admin-mbaas update --id=<mBaaS id> [--url=<mBaaS URL>] [--servicekey=<mBaaS Service Key>]
fhc admin-mbaas delete --id=<mBaaS id>

Where:
`id` is some unique identifier for this mBaaS
`url` is the hostname of the mBaaS
`servicekey` is the administrative service key used to communicate with the mBaaS. This can be provided by your operations engineer.
23 changes: 13 additions & 10 deletions lib/admin-environments.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var restfulCommand = require('./restful-cmd'),
autoDeploy = "[--autoDeployOnCreate=<true|false>] [--autoDeployOnUpdate=<true|false>]",
usage = "\nfhc admin-environments [list]"
+ "\nfhc admin-environments read --id=<environment id>"
+ "\nfhc admin-environments create --label=<label> --targets=<mbaasTargetId1>,<mbaasTargetId2>"
+ "\nfhc admin-environments update --id=<environment id> [--label=<label>] [--targets=<target1>,<target2>]"
+ "\nfhc admin-environments create --id=<environment id> --label=<label> --targets=<mbaasTargetId1>,<mbaasTargetId2> " + autoDeploy
+ "\nfhc admin-environments update --id=<environment id> [--label=<label>] [--targets=<target1>,<target2>] " + autoDeploy
+ "\nfhc admin-environments delete --id=<environment id>";

module.exports = restfulCommand({
Expand All @@ -19,18 +20,20 @@ module.exports = restfulCommand({
function _getCreateUpdateParams(ini, action, cb){
var label = ini.get('label'),
targets = ini.get('targets'),
id = ini.get('id'),
environment = {};
console.log('got id')
console.log(id)

if (action === 'create' && (!label || !targets)){
return cb('Create operations need a label and targets');
if (action === 'create' && (!label || !targets || !id)){
return cb('Create operations need an id, label and targets');
}
// Targets are comma separated
if (targets){
environment.targets = targets;
}
if (label){
environment.label = label;
}
environment.targets = targets;
environment._id = id;
environment.label = label;
environment.autoDeployOnCreate = ini.get('autoDeployOnCreate');
environment.autoDeployOnUpdate = ini.get('autoDeployOnUpdate');

return cb(null, environment);
}
21 changes: 9 additions & 12 deletions lib/admin-mbaas.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var restfulCommand = require('./restful-cmd'),
usage = "\nfhc admin-mbaas [list]"
+ "\nfhc admin-mbaas read --id=<mBaaS id>"
+ "\nfhc admin-mbaas create --url=<mBaaS URL> --key=<mBaaS Service Key>"
+ "\nfhc admin-mbaas update --id=<mBaaS id> [--url=<mBaaS URL>] [--key=<mBaaS Service Key>]"
+ "\nfhc admin-mbaas create --id=<mBaaS id> --url=<mBaaS URL> --servicekey=<mBaaS Service Key>"
+ "\nfhc admin-mbaas update --id=<mBaaS id> [--url=<mBaaS URL>] [--servicekey=<mBaaS Service Key>]"
+ "\nfhc admin-mbaas delete --id=<mBaaS id>"

module.exports = restfulCommand({
Expand All @@ -18,19 +18,16 @@ module.exports = restfulCommand({

function _getCreateUpdateParams(ini, action, cb){
var url = ini.get('url'),
key = ini.get('key'),
servicekey = ini.get('servicekey'),
id = ini.get('id'),
mBaaS = {};

if (action === 'create' && (!url || !key)){
return cb('Create operations need a url and key');
}
// Targets are comma separated
if (url){
mBaaS.url = url;
}
if (key){
mBaaS.key = key;
if (action === 'create' && (!url || !servicekey || !id)){
return cb('Create operations need an id, url and servicekey');
}
mBaaS.url = url;
mBaaS.servicekey = servicekey;
mBaaS._id = id;

return cb(null, mBaaS);
}
13 changes: 13 additions & 0 deletions man1/admin-environments.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.\" Generated with Ronnjs 0.4.0
.\" http://github.com/kapouer/ronnjs
fhc admin\-environments [list]
fhc admin\-environments read \-\-id=<environment id>
fhc admin\-environments create \-\-id=<environment id> \-\-label=<label> \-\-targets=<mbaasTargetId1>,<mbaasTargetId2> [\-\-autoDeployOnCreate=<true|false>] [\-\-autoDeployOnUpdate=<true|false>]
fhc admin\-environments update \-\-id=<environment id> [\-\-label=<label>] [\-\-targets=<target1>,<target2>] [\-\-autoDeployOnCreate=<true|false>] [\-\-autoDeployOnUpdate=<true|false>]
fhc admin\-environments delete \-\-id=<environment id>
.
.P
Where:
.
.br
\fBtargets\fR is a comma separated list of mBaaS hostnames which this environment should deploy to\. In most cases, this will be a single mBaaS\. To see a list of available mBaaS targets, use the \fBfhc admin\-mbaas\fR command\. \fBautoDeployOnCreate\fR automatically deploys cloud apps to this environment upon first creation\. This should be typically set to true for the first environment in your lifecycle chain (often \fBdev\fR), so that your new app is immediately previewable\. \fBautoDeployOnUpdate\fR automatically deploys cloud apps to this environment for all subsequent updates\.
13 changes: 13 additions & 0 deletions man1/admin-mbaas.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.\" Generated with Ronnjs 0.4.0
.\" http://github.com/kapouer/ronnjs
fhc admin\-mbaas [list]
fhc admin\-mbaas read \-\-id=<mBaaS id>
fhc admin\-mbaas create \-\-id=<mBaaS id> \-\-url=<mBaaS URL> \-\-servicekey=<mBaaS Service Key>
fhc admin\-mbaas update \-\-id=<mBaaS id> [\-\-url=<mBaaS URL>] [\-\-servicekey=<mBaaS Service Key>]
fhc admin\-mbaas delete \-\-id=<mBaaS id>
.
.P
Where:
.
.br
\fBid\fR is some unique identifier for this mBaaS \fBurl\fR is the hostname of the mBaaS \fBservicekey\fR is the administrative service key used to communicate with the mBaaS\. This can be provided by your operations engineer\.
2 changes: 1 addition & 1 deletion test/test_admin_environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
'test admin-environments create': function() {
fhc.load(function (er){
console.log("In test admin-environments create");
adminenvironments(['create', '--label=foo', '--targets=1,2,3'], function (err, data){
adminenvironments(['create', '--label=foo', '--targets=1,2,3', '--id=foo'], function (err, data){
assert.equal(err, null);
assert.equal(data.status, 'ok');
assert.equal(data.label, 'mynewenv');
Expand Down
4 changes: 2 additions & 2 deletions test/test_admin_mbaas.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var fhReq = require('./fixtures/fhreq.js')({
ini = require('./fixtures/ini.js')({
'id' : '1a',
'url' : 'http://mbaas.com',
'key' : '1a2b'
'servicekey' : '1a2b'
});
var restfulCmd = proxyquire('restful-cmd.js', {
'./utils/request' : fhReq,
Expand Down Expand Up @@ -53,7 +53,7 @@ module.exports = {
'test admin-mbaas create': function() {
fhc.load(function (er){
console.log("In test admin-mbaas create");
adminmbaas(['create', '--url=http://mbaas.com', '--key=1a2b'], function (err, data){
adminmbaas(['create', '--url=http://mbaas.com', '--key=1a2b', '--id=foo'], function (err, data){
assert.equal(err, null);
assert.equal(data.status, 'ok');
assert.equal(data.url, 'http://mbaas.com');
Expand Down

0 comments on commit fe5b762

Please sign in to comment.