Skip to content

Commit

Permalink
cluster props
Browse files Browse the repository at this point in the history
  • Loading branch information
craig committed Mar 12, 2015
1 parent bb7253f commit 858a0e0
Show file tree
Hide file tree
Showing 8 changed files with 859 additions and 3 deletions.
Empty file added VERSION.txt
Empty file.
8 changes: 5 additions & 3 deletions bin/fhc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var _completion = function(){
if(/^--\w?/.test(data.last)) return tabtab.log(['help', 'version'], data, '--');
..even out subcommands can go here
*/

var cmdList = _.filter(_.keys(fhc), function(key){ return key[0] !== '_'; });
tabtab.log(cmdList, data);
});
Expand All @@ -33,7 +33,7 @@ var _completion = function(){
// this is how to use fhc programmatically:
fhc.load(conf, function (err, conf) {
_completion();

if (err) return errorHandler(err);
var cmd = fhc.applyCommandFunction(argv, function(err, data){
if (err) return errorHandler(err);
Expand All @@ -45,14 +45,16 @@ fhc.load(conf, function (err, conf) {
output.write(cmd.bare, errorHandler);
}else {
// display table if both requested and supported..
console.log(conf);
console.log(cmd.table);
if (!conf.json && conf.table && (cmd && cmd.table || (data && data._table))) {
if (cmd && cmd.message) console.log(cmd.message);
var table = cmd.table || data._table;
console.log(table.toString());
output.write("", errorHandler);
}else{
if (data){
delete data._table;
delete data._table;
}
// check if we have a nonjson message
if(!conf.json && cmd && cmd.message) {
Expand Down
69 changes: 69 additions & 0 deletions lib/cmd/fh3/admin/clusterprops.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module.exports = clusterprops;

clusterprops.desc = "Manage clusterprops";
clusterprops.usage = "fhc admin clusterprops \n fhc admin clusterprops read <name> \n";

var common = require("../../../common");
var fhreq = require("../../../utils/request");
var ini = require('../../../utils/ini');
var _ = require('underscore');
var headers = ['Id', 'Environment', 'Connection Tag', 'Platform', 'Client App', 'Cloud App', 'Build Type', 'Status'];
var fields = ['guid', 'environment', 'tag', 'destination', 'clientApp', 'cloudApp', 'build', 'status'];

function unknown(message, cb) {
return cb(message + "\n" + "Usage: \n" + clusterprops.usage);
}

function clusterprops(argv, cb) {
var args = argv._;
if (args.length === 1) return listclusterprops(argv, cb);

var action = args[0];
if ("list" === action || undefined === action) {
return listclusterprops(argv, cb);
} if ("read" === action) {
//return readConnection(argv, cb);
} if ("update" === action) {
//return updateConnection(argv, cb);
} else {
return unknown("Invalid action: " + action, cb);
}
}

function listclusterprops(args, cb){
var url = "/box/api/clusters/properties";
common.doGetApiCall(fhreq.getFeedHenryUrl(), url, "Error reading Cluster Props: ", function(err, props){
if (err) return cb(err);
if (ini.get('table') === true) {
clusterprops.table = common.createTableForProperties("cluster",props);
}

return cb(err, props);
});
}

function readclusterprop(args, cb){
var url = "/box/api/clusters/properties";
common.doGetApiCall(fhreq.getFeedHenryUrl(), url, "Error reading Cluster Props: ", function(err, props){
if (err) return cb(err);
if (ini.get('table') === true) {
clusterprops.table = common.createTableForProperties("cluster",props);
}

return cb(err, props);
});
}


//module.exports = {
// 'desc' : 'read a clusters properties.',
// 'examples' : [{ cmd : 'fhc admin clusterprops ', desc : 'read a clusters props'}],
// 'demand' : [],
// 'alias' : {},
// 'describe' : {
// },
// 'url' : function(params){
// return '/box/api/clusters/properties'
// },
// 'method' : 'get'
//};
12 changes: 12 additions & 0 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ exports.createTableForProjects = function(projects) {
return table;
};

exports.createTableForProperties = function(type,properties){
var table = new Table({
head: ['guid', 'Name', 'Value'],
style: exports.style()
});
_.each(properties, function(prop){
prop.guid = prop.guid || "none";
table.push([prop.guid, prop.name, prop.value]);
}, this);
return table;
};

exports.createTableForMbaasTargets = function(mbaas_targets) {
var table = new Table({
head: ['ID', 'URL', 'Service Key', 'Username', 'Password', 'Modified'],
Expand Down
Empty file added lib/migrate.js
Empty file.
Empty file added man1/migrate.1
Empty file.
17 changes: 17 additions & 0 deletions test-form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"updatedBy": "[email protected]",
"name": "sdsd",
"description": "",
"subscribers": [],
"pageRules": [],
"fieldRules": [],
"pages": [
{
"fields": []
}
],
"lastUpdated": "2014-04-29T11:46:20.489Z",
"dateCreated": "2014-04-29T11:46:20.489Z",
"status": "ok",
"statusCode": 200
}
Loading

0 comments on commit 858a0e0

Please sign in to comment.