joyent/node-triton#154 #108 changes broke triton cloudapi ...
This commit is contained in:
parent
ad7d608011
commit
f7bbe5fcff
@ -7,6 +7,8 @@ Known issues:
|
||||
|
||||
## not yet released
|
||||
|
||||
- [joyent/node-triton#154] Fix `triton cloudapi ...` after #108 changes.
|
||||
|
||||
- **BREAKING CHANGE for module usage of node-triton.**
|
||||
To implement joyent/node-triton#108, the way a TritonApi client is
|
||||
setup for use has changed from being (unrealistically) sync to async.
|
||||
|
@ -11,7 +11,9 @@
|
||||
*/
|
||||
|
||||
var http = require('http');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('./common');
|
||||
var errors = require('./errors');
|
||||
|
||||
|
||||
@ -62,27 +64,34 @@ function do_cloudapi(subcmd, opts, args, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
this.tritonapi.cloudapi._request(reqOpts, function (err, req, res, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (opts.headers || reqOpts.method === 'head') {
|
||||
console.error('%s/%s %d %s',
|
||||
req.connection.encrypted ? 'HTTPS' : 'HTTP',
|
||||
res.httpVersion,
|
||||
res.statusCode,
|
||||
http.STATUS_CODES[res.statusCode]);
|
||||
Object.keys(res.headers).forEach(function (key) {
|
||||
console.error('%s: %s', key, res.headers[key]);
|
||||
});
|
||||
console.error();
|
||||
}
|
||||
vasync.pipeline({arg: {cli: this}, funcs: [
|
||||
common.cliSetupTritonApi,
|
||||
|
||||
if (reqOpts.method !== 'head')
|
||||
console.log(JSON.stringify(body, null, 4));
|
||||
callback();
|
||||
});
|
||||
function callCloudapi(ctx, next) {
|
||||
var cloudapi = ctx.cli.tritonapi.cloudapi;
|
||||
cloudapi._request(reqOpts, function (err, req, res, body) {
|
||||
if (err) {
|
||||
next(err);
|
||||
return;
|
||||
}
|
||||
if (opts.headers || reqOpts.method === 'head') {
|
||||
console.error('%s/%s %d %s',
|
||||
req.connection.encrypted ? 'HTTPS' : 'HTTP',
|
||||
res.httpVersion,
|
||||
res.statusCode,
|
||||
http.STATUS_CODES[res.statusCode]);
|
||||
Object.keys(res.headers).forEach(function (key) {
|
||||
console.error('%s: %s', key, res.headers[key]);
|
||||
});
|
||||
console.error();
|
||||
}
|
||||
|
||||
if (reqOpts.method !== 'head')
|
||||
console.log(JSON.stringify(body, null, 4));
|
||||
next();
|
||||
});
|
||||
}
|
||||
]}, callback);
|
||||
}
|
||||
|
||||
do_cloudapi.options = [
|
||||
|
Reference in New Issue
Block a user