diff --git a/lib/cloudapi2.js b/lib/cloudapi2.js index 5b68405..ba06a39 100644 --- a/lib/cloudapi2.js +++ b/lib/cloudapi2.js @@ -181,7 +181,7 @@ CloudAPI.prototype._qs = function _qs(/* fields1, ...*/) { * Optionally an object of query params can be passed in to include a query * string. This just calls `this._qs(...)`. */ -CloudAPI.prototype._path = function _path(subpath /*, qparams, ... */) { +CloudAPI.prototype._path = function _path(subpath /* , qparams, ... */) { assert.string(subpath, 'subpath'); assert.ok(subpath[0] === '/'); @@ -301,7 +301,8 @@ CloudAPI.prototype.listServices = function listServices(opts, cb) { /** * Get datacenters information * - * @param {Function} callback of the form `function (err, datacenters, response)` + * @param {Function} callback of the form + * `function (err, datacenters, response)` */ CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) { var endpoint = sprintf('/%s/datacenters', this.user); @@ -492,7 +493,8 @@ CloudAPI.prototype._doMachine = function _doMachine(action, uuid, callback) { * - {Number} interval (optional) - time in ms to poll * @param {Function} callback - called when state is reached or on error */ -CloudAPI.prototype.waitForMachineStates = function waitForMachineStates(opts, callback) { +CloudAPI.prototype.waitForMachineStates = + function waitForMachineStates(opts, callback) { var self = this; assert.object(opts, 'opts'); assert.string(opts.id, 'opts.id'); @@ -618,7 +620,7 @@ CloudAPI.prototype.machineAudit = function machineAudit(options, callback) { assert.func(callback, 'callback'); var path = sprintf('/%s/machines/%s/audit', self.user, options.id); - //XXX This `client.get` block is duplicated. Add a convenience function for it: + // XXX This `client.get` block is duplicated. Add a convenience func for it: self._getAuthHeaders(function (hErr, headers) { if (hErr) { callback(hErr); diff --git a/lib/common.js b/lib/common.js index a6b90d2..1a3de1a 100755 --- a/lib/common.js +++ b/lib/common.js @@ -95,14 +95,14 @@ function kvToObj(kvs, valid) { var idx = kv.indexOf('='); if (idx === -1) throw new errors.UsageError(format( - 'invalid filter: "%s" (must be of the form "field=value")', - kv)); + 'invalid filter: "%s" (must be of the form "field=value")', + kv)); var k = kv.slice(0, idx); var v = kv.slice(idx + 1); if (valid.indexOf(k) === -1) throw new errors.UsageError(format( - 'invalid filter name: "%s" (must be one of "%s")', - k, valid.join('", "'))); + 'invalid filter name: "%s" (must be one of "%s")', + k, valid.join('", "'))); o[k] = v; } return o; diff --git a/lib/config.js b/lib/config.js index a62794e..e76e5e7 100755 --- a/lib/config.js +++ b/lib/config.js @@ -12,7 +12,8 @@ var common = require('./common'); var errors = require('./errors'); -var DEFAULT_USER_CONFIG_PATH = path.resolve(process.env.HOME, '.triton', 'config.json'); +var DEFAULT_USER_CONFIG_PATH = path.resolve(process.env.HOME, + '.triton', 'config.json'); var DEFAULTS_PATH = path.resolve(__dirname, '..', 'etc', 'defaults.json'); var OVERRIDE_KEYS = []; // config object keys to do a one-level deep override diff --git a/lib/do_cloudapi.js b/lib/do_cloudapi.js index 316f78a..1d56125 100644 --- a/lib/do_cloudapi.js +++ b/lib/do_cloudapi.js @@ -6,7 +6,7 @@ var http = require('http'); -function do_cloudapi (subcmd, opts, args, callback) { +function do_cloudapi(subcmd, opts, args, callback) { if (opts.help) { this.do_help('help', {}, [subcmd], callback); return; diff --git a/lib/do_create_instance.js b/lib/do_create_instance.js index 4dd809a..c06b6f3 100644 --- a/lib/do_create_instance.js +++ b/lib/do_create_instance.js @@ -82,7 +82,7 @@ function do_create_instance(subcmd, opts, args, callback) { name: 'm00' }; console.log('Creating instance %s (%s, %s@%s)', - ctx.inst.name, ctx.inst.id, + ctx.inst.name, ctx.inst.id, ctx.img.name, ctx.img.version); return next(); } diff --git a/lib/do_instance_audit.js b/lib/do_instance_audit.js index 74983f4..0deaa4d 100644 --- a/lib/do_instance_audit.js +++ b/lib/do_instance_audit.js @@ -31,13 +31,15 @@ function do_instance_audit(subcmd, opts, args, callback) { if (opts.json) { common.jsonStream(audit); } else { - return callback(new errors.InternalError("tabular output for audit NYI")); // XXX - //common.tabulate(audit, { + // XXX what to tabulate here? + return callback( + new errors.InternalError('tabular output for audit NYI')); + // common.tabulate(audit, { // columns: 'dc,id,name,state,created', // sort: 'created', // validFields: 'dc,id,name,type,state,image,package,memory,' // + 'disk,created,updated,compute_node,primaryIp' - //}); + // }); } callback(); }); diff --git a/lib/do_packages.js b/lib/do_packages.js index 9b769c0..9c45bb0 100644 --- a/lib/do_packages.js +++ b/lib/do_packages.js @@ -8,7 +8,7 @@ var tabula = require('tabula'); var common = require('./common'); -function do_packages (subcmd, opts, args, callback) { +function do_packages(subcmd, opts, args, callback) { if (opts.help) { this.do_help('help', {}, [subcmd], callback); return; diff --git a/lib/do_profile.js b/lib/do_profile.js index 967a7c5..98894ca 100644 --- a/lib/do_profile.js +++ b/lib/do_profile.js @@ -8,7 +8,7 @@ var common = require('./common'); -function do_profile (subcmd, opts, args, callback) { +function do_profile(subcmd, opts, args, callback) { if (opts.help) { this.do_help('help', {}, [subcmd], callback); return; diff --git a/lib/do_wait_instance.js b/lib/do_wait_instance.js index 748a9d1..18b48b4 100644 --- a/lib/do_wait_instance.js +++ b/lib/do_wait_instance.js @@ -20,6 +20,7 @@ function do_wait_instance(subcmd, opts, args, cb) { var ids = args; var states = []; opts.states.forEach(function (s) { + /* JSSTYLED */ states = states.concat(s.trim().split(/\s*,\s*/g)); }); @@ -65,8 +66,8 @@ function do_wait_instance(subcmd, opts, args, cb) { idsToWaitFor.length, states.join(', ')); } - if (false /* TODO: need BigSpinner.log first */ - && !opts.quiet && process.stderr.isTTY) + if (false && /* TODO: need BigSpinner.log first */ + !opts.quiet && process.stderr.isTTY) { distraction = distractions.createDistraction(); } diff --git a/lib/triton.js b/lib/triton.js index dca383b..1f1f772 100644 --- a/lib/triton.js +++ b/lib/triton.js @@ -13,6 +13,9 @@ var format = require('util').format; var once = require('once'); var path = require('path'); var restifyClients = require('restify-clients'); +// We are cheating here. restify-clients should export its 'bunyan'. +var restifyBunyanSerializers = + require('restify-clients/lib/helpers/bunyan').serializers; var tabula = require('tabula'); var vasync = require('vasync'); @@ -51,8 +54,7 @@ function Triton(options) { (!options.log.serializers.client_req || !options.log.serializers.client_req)) { this.log = options.log.child({ - // XXX cheating. restify-clients should export its 'bunyan'. - serializers: require('restify-clients/lib/helpers/bunyan').serializers + serializers: restifyBunyanSerializers }); } else { this.log = options.log; @@ -142,8 +144,8 @@ Triton.prototype.listImages = function listImages(opts, cb) { if (opts.useCache) { fs.readFile(cacheFile, 'utf8', function (err, out) { if (err) { - self.log.info({err: err}, 'failed to read cache file %s', - cacheFile); + self.log.info({err: err, cacheFile: cacheFile}, + 'failed to read cache file'); fetch(); return; } @@ -151,7 +153,8 @@ Triton.prototype.listImages = function listImages(opts, cb) { try { data = JSON.parse(out); } catch (e) { - self.log.info({err: e}, 'failed to parse cache file %s', cacheFile); + self.log.info({err: e, cacheFile: cacheFile}, + 'failed to parse cache file'); fetch(); return; } @@ -167,9 +170,12 @@ Triton.prototype.listImages = function listImages(opts, cb) { if (!err && self.cacheDir) { // cache the results var data = JSON.stringify(imgs); - fs.writeFile(cacheFile, data, {encoding: 'utf8'}, function (err2) { - if (err2) - self.log.info({err: err2}, 'error caching images results'); + fs.writeFile(cacheFile, data, {encoding: 'utf8'}, + function (err2) { + if (err2) { + self.log.info({err: err2}, + 'error caching images results'); + } done(); }); } else {