'make check-jsl' clean

This commit is contained in:
Trent Mick 2015-09-01 09:00:45 -07:00
parent 42f0ee5a41
commit 9241f90ccf
11 changed files with 40 additions and 44 deletions

View File

@ -24,8 +24,6 @@
* *
*/ */
var p = console.log;
var assert = require('assert-plus'); var assert = require('assert-plus');
var auth = require('smartdc-auth'); var auth = require('smartdc-auth');
var format = require('util').format; var format = require('util').format;
@ -215,8 +213,13 @@ CloudAPI.prototype._request = function _request(options, callback) {
assert.ok(['get', 'post', 'delete', 'head'].indexOf(method) >= 0, assert.ok(['get', 'post', 'delete', 'head'].indexOf(method) >= 0,
'invalid method given'); 'invalid method given');
switch (method) { switch (method) {
case 'delete': method = 'del'; break; case 'delete':
method = 'del';
break;
default:
break;
} }
self._getAuthHeaders(function (err, headers) { self._getAuthHeaders(function (err, headers) {
if (err) { if (err) {
callback(err); callback(err);

View File

@ -221,6 +221,7 @@ function humanSizeFromBytes(opts, bytes) {
} }
} else if (opts.narrow && !hasDecimal) { } else if (opts.narrow && !hasDecimal) {
/* skip all-zero precision */ /* skip all-zero precision */
/* jsl:pass */
} else { } else {
if (!hasDecimal) { if (!hasDecimal) {
s += '.'; s += '.';
@ -269,13 +270,12 @@ function normShortId(s) {
shortId = shortId.replace(/-+$/, ''); shortId = shortId.replace(/-+$/, '');
} else { } else {
// UUID prefix. // UUID prefix.
var shortId = ''; shortId = '';
var chunk;
var remaining = s; var remaining = s;
var spans = [8, 4, 4, 4, 12]; var spans = [8, 4, 4, 4, 12];
for (var i = 0; i < spans.length; i++) { for (var i = 0; i < spans.length; i++) {
var span = spans[i]; var span = spans[i];
head = remaining.slice(0, span); var head = remaining.slice(0, span);
remaining = remaining.slice(span + 1); remaining = remaining.slice(span + 1);
if (!shortIdCharsRe.test(head)) { if (!shortIdCharsRe.test(head)) {
return; return;

View File

@ -73,17 +73,6 @@ function loadConfigSync(opts) {
} }
/**
* Apply the given key:value updates to the user config and save it out.
*
* @param config {Object} The loaded config, as from `loadConfigSync`.
* @param updates {Object} key/value pairs to update.
*/
function updateUserConfigSync(config, updates) {
XXX
///XXX START HERE: to implement for 'sdc dcs add foo bar'
}
//---- exports //---- exports

View File

@ -12,7 +12,7 @@ var path = require('path');
function do_badger(subcmd, opts, args, callback) { function do_badger(subcmd, opts, args, callback) {
var callbackOnce = once(callback); var callbackOnce = once(callback);
var badger = path.resolve(__dirname, '../etc/badger'); var badger = path.resolve(__dirname, '../etc/badger');
var input = fs.createReadStream(badger) var input = fs.createReadStream(badger);
input.pipe(process.stdout); input.pipe(process.stdout);
input.on('error', function (err) { input.on('error', function (err) {
callbackOnce(err); callbackOnce(err);
@ -20,10 +20,10 @@ function do_badger(subcmd, opts, args, callback) {
input.on('end', function () { input.on('end', function () {
callbackOnce(); callbackOnce();
}); });
}; }
do_badger.options = []; do_badger.options = [];
do_badger.help = 'Rawr!'; do_badger.help = 'Badger don\'t care.';
do_badger.hidden = true; do_badger.hidden = true;
module.exports = do_badger; module.exports = do_badger;

View File

@ -25,7 +25,6 @@ function do_create_instance(subcmd, opts, args, callback) {
var log = this.triton.log; var log = this.triton.log;
var cloudapi = this.triton.cloudapi; var cloudapi = this.triton.cloudapi;
var cOpts = {};
vasync.pipeline({arg: {}, funcs: [ vasync.pipeline({arg: {}, funcs: [
function getImg(ctx, next) { function getImg(ctx, next) {
@ -78,13 +77,13 @@ function do_create_instance(subcmd, opts, args, callback) {
'create-instance createOpts'); 'create-instance createOpts');
ctx.start = Date.now(); ctx.start = Date.now();
if (opts.dry_run) { if (opts.dry_run) {
var inst = ctx.inst = { ctx.inst = {
id: 'beefbeef-4c0e-11e5-86cd-a7fd38d2a50b', id: 'beefbeef-4c0e-11e5-86cd-a7fd38d2a50b',
name: 'm00' name: 'm00'
}; };
console.log('Creating instance %s (%s, %s@%s%s)', console.log('Creating instance %s (%s, %s@%s)',
inst.name, inst.id, ctx.img.name, ctx.img.version, ctx.inst.name, ctx.inst.id,
inst.package ? format(', %s', inst.package) : ''); ctx.img.name, ctx.img.version);
return next(); return next();
} }
@ -160,7 +159,7 @@ function do_create_instance(subcmd, opts, args, callback) {
]}, function (err) { ]}, function (err) {
callback(err); callback(err);
}); });
}; }
do_create_instance.options = [ do_create_instance.options = [
{ {

View File

@ -30,7 +30,7 @@ function do_image(subcmd, opts, args, callback) {
} }
callback(); callback();
}); });
}; }
do_image.options = [ do_image.options = [
{ {

View File

@ -81,7 +81,7 @@ function do_images(subcmd, opts, args, callback) {
} }
callback(); callback();
}); });
}; }
do_images.options = [ do_images.options = [
{ {

View File

@ -7,11 +7,11 @@
var format = require('util').format; var format = require('util').format;
var tabula = require('tabula'); var tabula = require('tabula');
var common = require('./common');
var errors = require('./errors'); var errors = require('./errors');
function do_instance_audit(subcmd, opts, args, callback) { function do_instance_audit(subcmd, opts, args, callback) {
var self = this;
if (opts.help) { if (opts.help) {
this.do_help('help', {}, [subcmd], callback); this.do_help('help', {}, [subcmd], callback);
return; return;
@ -29,9 +29,9 @@ function do_instance_audit(subcmd, opts, args, callback) {
audit[i].dc = dc; audit[i].dc = dc;
} }
if (opts.json) { if (opts.json) {
p(JSON.stringify(audit, null, 4)); common.jsonStream(audit);
} else { } else {
return callback(new error.InternalError("tabular output for audit NYI")); // XXX return callback(new errors.InternalError("tabular output for audit NYI")); // XXX
//common.tabulate(audit, { //common.tabulate(audit, {
// columns: 'dc,id,name,state,created', // columns: 'dc,id,name,state,created',
// sort: 'created', // sort: 'created',
@ -41,7 +41,8 @@ function do_instance_audit(subcmd, opts, args, callback) {
} }
callback(); callback();
}); });
}; }
do_instance_audit.options = [ do_instance_audit.options = [
{ {
names: ['help', 'h'], names: ['help', 'h'],

View File

@ -30,7 +30,7 @@ function do_package(subcmd, opts, args, callback) {
} }
callback(); callback();
}); });
}; }
do_package.options = [ do_package.options = [
{ {

View File

@ -24,7 +24,7 @@ function do_profile (subcmd, opts, args, callback) {
.join(','); .join(',');
} }
if (opts.json) { if (opts.json) {
p(JSON.stringify(profs, null, 4)); common.jsonStream(profs);
} else { } else {
common.tabulate(profs, { common.tabulate(profs, {
columns: 'curr,name,dcs,user,keyId', columns: 'curr,name,dcs,user,keyId',
@ -33,7 +33,7 @@ function do_profile (subcmd, opts, args, callback) {
}); });
} }
callback(); callback();
}; }
do_profile.options = [ do_profile.options = [
{ {

View File

@ -37,7 +37,7 @@ function do_startstop_instance(action) {
names: ['wait', 'w'], names: ['wait', 'w'],
type: 'bool', type: 'bool',
help: 'Block until desired state is reached.' help: 'Block until desired state is reached.'
}, }
]; ];
return _do_startstop_instance; return _do_startstop_instance;
@ -66,6 +66,9 @@ function _do_instance(action, subcmd, opts, args, callback) {
command = 'deleteMachine'; command = 'deleteMachine';
state = 'deleted'; state = 'deleted';
break; break;
default:
callback(new Error('unknown action: ' + action));
break;
} }
if (opts.help) { if (opts.help) {
@ -83,13 +86,13 @@ function _do_instance(action, subcmd, opts, args, callback) {
uuid = arg; uuid = arg;
go1(); go1();
} else { } else {
self.triton.getInstance(arg, function (err, machine) { self.triton.getInstance(arg, function (err, inst) {
if (err) { if (err) {
callback(err); callback(err);
return; return;
} }
alias = arg; alias = arg;
uuid = machine.id; uuid = inst.id;
go1(); go1();
}); });
} }
@ -116,11 +119,12 @@ function _do_instance(action, subcmd, opts, args, callback) {
self.triton.cloudapi.waitForMachineStates({ self.triton.cloudapi.waitForMachineStates({
id: uuid, id: uuid,
states: [state] states: [state]
}, function (err, machine, res) { }, function (err2, inst2, res2) {
if (action === 'delete' && res && res.statusCode === 410) { if (action === 'delete' && res2 && res2.statusCode === 410) {
// this is success, fall through to bottom // This is success, fall through to bottom.
} else if (err) { /* jsl:pass */
callback(err); } else if (err2) {
callback(err2);
return; return;
} }