joyent/node-triton#154 #108 changes broke triton cloudapi ...

This commit is contained in:
Trent Mick 2016-12-14 11:01:18 -08:00
parent ad7d608011
commit f7bbe5fcff
2 changed files with 31 additions and 20 deletions

View File

@ -7,6 +7,8 @@ Known issues:
## not yet released ## not yet released
- [joyent/node-triton#154] Fix `triton cloudapi ...` after #108 changes.
- **BREAKING CHANGE for module usage of node-triton.** - **BREAKING CHANGE for module usage of node-triton.**
To implement joyent/node-triton#108, the way a TritonApi client is To implement joyent/node-triton#108, the way a TritonApi client is
setup for use has changed from being (unrealistically) sync to async. setup for use has changed from being (unrealistically) sync to async.

View File

@ -11,7 +11,9 @@
*/ */
var http = require('http'); var http = require('http');
var vasync = require('vasync');
var common = require('./common');
var errors = require('./errors'); var errors = require('./errors');
@ -62,9 +64,14 @@ function do_cloudapi(subcmd, opts, args, callback) {
} }
} }
this.tritonapi.cloudapi._request(reqOpts, function (err, req, res, body) { vasync.pipeline({arg: {cli: this}, funcs: [
common.cliSetupTritonApi,
function callCloudapi(ctx, next) {
var cloudapi = ctx.cli.tritonapi.cloudapi;
cloudapi._request(reqOpts, function (err, req, res, body) {
if (err) { if (err) {
callback(err); next(err);
return; return;
} }
if (opts.headers || reqOpts.method === 'head') { if (opts.headers || reqOpts.method === 'head') {
@ -81,8 +88,10 @@ function do_cloudapi(subcmd, opts, args, callback) {
if (reqOpts.method !== 'head') if (reqOpts.method !== 'head')
console.log(JSON.stringify(body, null, 4)); console.log(JSON.stringify(body, null, 4));
callback(); next();
}); });
}
]}, callback);
} }
do_cloudapi.options = [ do_cloudapi.options = [