From 9241f90ccf567b75ccf2cb47386a09a3701bd900 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 1 Sep 2015 09:00:45 -0700 Subject: [PATCH] 'make check-jsl' clean --- lib/cloudapi2.js | 9 ++++++--- lib/common.js | 6 +++--- lib/config.js | 11 ----------- lib/do_badger.js | 6 +++--- lib/do_create_instance.js | 11 +++++------ lib/do_image.js | 2 +- lib/do_images.js | 2 +- lib/do_instance_audit.js | 9 +++++---- lib/do_package.js | 2 +- lib/do_profile.js | 6 +++--- lib/do_startstop_instance.js | 20 ++++++++++++-------- 11 files changed, 40 insertions(+), 44 deletions(-) diff --git a/lib/cloudapi2.js b/lib/cloudapi2.js index 28d5d44..63de417 100644 --- a/lib/cloudapi2.js +++ b/lib/cloudapi2.js @@ -24,8 +24,6 @@ * */ -var p = console.log; - var assert = require('assert-plus'); var auth = require('smartdc-auth'); 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, 'invalid method given'); switch (method) { - case 'delete': method = 'del'; break; + case 'delete': + method = 'del'; + break; + default: + break; } + self._getAuthHeaders(function (err, headers) { if (err) { callback(err); diff --git a/lib/common.js b/lib/common.js index b7a6750..3248a83 100755 --- a/lib/common.js +++ b/lib/common.js @@ -221,6 +221,7 @@ function humanSizeFromBytes(opts, bytes) { } } else if (opts.narrow && !hasDecimal) { /* skip all-zero precision */ + /* jsl:pass */ } else { if (!hasDecimal) { s += '.'; @@ -269,13 +270,12 @@ function normShortId(s) { shortId = shortId.replace(/-+$/, ''); } else { // UUID prefix. - var shortId = ''; - var chunk; + shortId = ''; var remaining = s; var spans = [8, 4, 4, 4, 12]; for (var i = 0; i < spans.length; i++) { var span = spans[i]; - head = remaining.slice(0, span); + var head = remaining.slice(0, span); remaining = remaining.slice(span + 1); if (!shortIdCharsRe.test(head)) { return; diff --git a/lib/config.js b/lib/config.js index c6044cc..6624da1 100755 --- a/lib/config.js +++ b/lib/config.js @@ -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 diff --git a/lib/do_badger.js b/lib/do_badger.js index 607d309..99e7dec 100644 --- a/lib/do_badger.js +++ b/lib/do_badger.js @@ -12,7 +12,7 @@ var path = require('path'); function do_badger(subcmd, opts, args, callback) { var callbackOnce = once(callback); var badger = path.resolve(__dirname, '../etc/badger'); - var input = fs.createReadStream(badger) + var input = fs.createReadStream(badger); input.pipe(process.stdout); input.on('error', function (err) { callbackOnce(err); @@ -20,10 +20,10 @@ function do_badger(subcmd, opts, args, callback) { input.on('end', function () { callbackOnce(); }); -}; +} do_badger.options = []; -do_badger.help = 'Rawr!'; +do_badger.help = 'Badger don\'t care.'; do_badger.hidden = true; module.exports = do_badger; diff --git a/lib/do_create_instance.js b/lib/do_create_instance.js index 6d8e7bb..0101ca8 100644 --- a/lib/do_create_instance.js +++ b/lib/do_create_instance.js @@ -25,7 +25,6 @@ function do_create_instance(subcmd, opts, args, callback) { var log = this.triton.log; var cloudapi = this.triton.cloudapi; - var cOpts = {}; vasync.pipeline({arg: {}, funcs: [ function getImg(ctx, next) { @@ -78,13 +77,13 @@ function do_create_instance(subcmd, opts, args, callback) { 'create-instance createOpts'); ctx.start = Date.now(); if (opts.dry_run) { - var inst = ctx.inst = { + ctx.inst = { id: 'beefbeef-4c0e-11e5-86cd-a7fd38d2a50b', name: 'm00' }; - console.log('Creating instance %s (%s, %s@%s%s)', - inst.name, inst.id, ctx.img.name, ctx.img.version, - inst.package ? format(', %s', inst.package) : ''); + console.log('Creating instance %s (%s, %s@%s)', + ctx.inst.name, ctx.inst.id, + ctx.img.name, ctx.img.version); return next(); } @@ -160,7 +159,7 @@ function do_create_instance(subcmd, opts, args, callback) { ]}, function (err) { callback(err); }); -}; +} do_create_instance.options = [ { diff --git a/lib/do_image.js b/lib/do_image.js index fe98d85..2d33003 100644 --- a/lib/do_image.js +++ b/lib/do_image.js @@ -30,7 +30,7 @@ function do_image(subcmd, opts, args, callback) { } callback(); }); -}; +} do_image.options = [ { diff --git a/lib/do_images.js b/lib/do_images.js index 9d1fc36..b8c4462 100644 --- a/lib/do_images.js +++ b/lib/do_images.js @@ -81,7 +81,7 @@ function do_images(subcmd, opts, args, callback) { } callback(); }); -}; +} do_images.options = [ { diff --git a/lib/do_instance_audit.js b/lib/do_instance_audit.js index 125b5b9..74983f4 100644 --- a/lib/do_instance_audit.js +++ b/lib/do_instance_audit.js @@ -7,11 +7,11 @@ var format = require('util').format; var tabula = require('tabula'); +var common = require('./common'); var errors = require('./errors'); function do_instance_audit(subcmd, opts, args, callback) { - var self = this; if (opts.help) { this.do_help('help', {}, [subcmd], callback); return; @@ -29,9 +29,9 @@ function do_instance_audit(subcmd, opts, args, callback) { audit[i].dc = dc; } if (opts.json) { - p(JSON.stringify(audit, null, 4)); + common.jsonStream(audit); } 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, { // columns: 'dc,id,name,state,created', // sort: 'created', @@ -41,7 +41,8 @@ function do_instance_audit(subcmd, opts, args, callback) { } callback(); }); -}; +} + do_instance_audit.options = [ { names: ['help', 'h'], diff --git a/lib/do_package.js b/lib/do_package.js index 2e9318b..4a62d6f 100644 --- a/lib/do_package.js +++ b/lib/do_package.js @@ -30,7 +30,7 @@ function do_package(subcmd, opts, args, callback) { } callback(); }); -}; +} do_package.options = [ { diff --git a/lib/do_profile.js b/lib/do_profile.js index 48555ea..967a7c5 100644 --- a/lib/do_profile.js +++ b/lib/do_profile.js @@ -24,7 +24,7 @@ function do_profile (subcmd, opts, args, callback) { .join(','); } if (opts.json) { - p(JSON.stringify(profs, null, 4)); + common.jsonStream(profs); } else { common.tabulate(profs, { columns: 'curr,name,dcs,user,keyId', @@ -33,7 +33,7 @@ function do_profile (subcmd, opts, args, callback) { }); } callback(); -}; +} do_profile.options = [ { @@ -57,4 +57,4 @@ do_profile.help = ( ); -module.exports = do_profile; \ No newline at end of file +module.exports = do_profile; diff --git a/lib/do_startstop_instance.js b/lib/do_startstop_instance.js index 5a4685d..73dcd20 100644 --- a/lib/do_startstop_instance.js +++ b/lib/do_startstop_instance.js @@ -37,7 +37,7 @@ function do_startstop_instance(action) { names: ['wait', 'w'], type: 'bool', help: 'Block until desired state is reached.' - }, + } ]; return _do_startstop_instance; @@ -66,6 +66,9 @@ function _do_instance(action, subcmd, opts, args, callback) { command = 'deleteMachine'; state = 'deleted'; break; + default: + callback(new Error('unknown action: ' + action)); + break; } if (opts.help) { @@ -83,13 +86,13 @@ function _do_instance(action, subcmd, opts, args, callback) { uuid = arg; go1(); } else { - self.triton.getInstance(arg, function (err, machine) { + self.triton.getInstance(arg, function (err, inst) { if (err) { callback(err); return; } alias = arg; - uuid = machine.id; + uuid = inst.id; go1(); }); } @@ -116,11 +119,12 @@ function _do_instance(action, subcmd, opts, args, callback) { self.triton.cloudapi.waitForMachineStates({ id: uuid, states: [state] - }, function (err, machine, res) { - if (action === 'delete' && res && res.statusCode === 410) { - // this is success, fall through to bottom - } else if (err) { - callback(err); + }, function (err2, inst2, res2) { + if (action === 'delete' && res2 && res2.statusCode === 410) { + // This is success, fall through to bottom. + /* jsl:pass */ + } else if (err2) { + callback(err2); return; }