sprintf was a lie - use format everywhere
This commit is contained in:
		
							parent
							
								
									716976efa8
								
							
						
					
					
						commit
						804fe155b9
					
				@ -31,7 +31,6 @@ var LOMStream = require('lomstream').LOMStream;
 | 
				
			|||||||
var os = require('os');
 | 
					var os = require('os');
 | 
				
			||||||
var querystring = require('querystring');
 | 
					var querystring = require('querystring');
 | 
				
			||||||
var restifyClients = require('restify-clients');
 | 
					var restifyClients = require('restify-clients');
 | 
				
			||||||
var sprintf = require('util').format;
 | 
					 | 
				
			||||||
var vasync = require('vasync');
 | 
					var vasync = require('vasync');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var errors = require('./errors');
 | 
					var errors = require('./errors');
 | 
				
			||||||
@ -105,7 +104,7 @@ function CloudAPI(options) {
 | 
				
			|||||||
        options.version = '*';
 | 
					        options.version = '*';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!options.userAgent) {
 | 
					    if (!options.userAgent) {
 | 
				
			||||||
        options.userAgent = sprintf('triton/%s (%s-%s; node/%s)',
 | 
					        options.userAgent = format('triton/%s (%s-%s; node/%s)',
 | 
				
			||||||
            VERSION, OS_ARCH, OS_PLATFORM, process.versions.node);
 | 
					            VERSION, OS_ARCH, OS_PLATFORM, process.versions.node);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -140,7 +139,7 @@ CloudAPI.prototype._getAuthHeaders = function _getAuthHeaders(callback) {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        headers.authorization = sprintf(
 | 
					        headers.authorization = format(
 | 
				
			||||||
            'Signature keyId="/%s/keys/%s",algorithm="%s",signature="%s"',
 | 
					            'Signature keyId="/%s/keys/%s",algorithm="%s",signature="%s"',
 | 
				
			||||||
            self.user, sig.keyId, sig.algorithm, sig.signature);
 | 
					            self.user, sig.keyId, sig.algorithm, sig.signature);
 | 
				
			||||||
        callback(null, headers);
 | 
					        callback(null, headers);
 | 
				
			||||||
@ -294,7 +293,7 @@ CloudAPI.prototype.getNetwork = function getNetwork(id, cb) {
 | 
				
			|||||||
 * @param {Function} callback of the form `function (err, services, response)`
 | 
					 * @param {Function} callback of the form `function (err, services, response)`
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CloudAPI.prototype.listServices = function listServices(opts, cb) {
 | 
					CloudAPI.prototype.listServices = function listServices(opts, cb) {
 | 
				
			||||||
    var endpoint = sprintf('/%s/services', this.user);
 | 
					    var endpoint = format('/%s/services', this.user);
 | 
				
			||||||
    this._passThrough(endpoint, opts, cb);
 | 
					    this._passThrough(endpoint, opts, cb);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -305,7 +304,7 @@ CloudAPI.prototype.listServices = function listServices(opts, cb) {
 | 
				
			|||||||
 *      `function (err, datacenters, response)`
 | 
					 *      `function (err, datacenters, response)`
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) {
 | 
					CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) {
 | 
				
			||||||
    var endpoint = sprintf('/%s/datacenters', this.user);
 | 
					    var endpoint = format('/%s/datacenters', this.user);
 | 
				
			||||||
    this._passThrough(endpoint, opts, cb);
 | 
					    this._passThrough(endpoint, opts, cb);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -317,7 +316,7 @@ CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) {
 | 
				
			|||||||
 * @param {Function} callback of the form `function (err, account, response)`
 | 
					 * @param {Function} callback of the form `function (err, account, response)`
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CloudAPI.prototype.getAccount = function getAccount(opts, cb) {
 | 
					CloudAPI.prototype.getAccount = function getAccount(opts, cb) {
 | 
				
			||||||
    var endpoint = sprintf('/%s', this.user);
 | 
					    var endpoint = format('/%s', this.user);
 | 
				
			||||||
    this._passThrough(endpoint, opts, cb);
 | 
					    this._passThrough(endpoint, opts, cb);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -327,7 +326,7 @@ CloudAPI.prototype.getAccount = function getAccount(opts, cb) {
 | 
				
			|||||||
 * @param {Function} callback of the form `function (err, keys, response)`
 | 
					 * @param {Function} callback of the form `function (err, keys, response)`
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CloudAPI.prototype.listKeys = function listKeys(opts, cb) {
 | 
					CloudAPI.prototype.listKeys = function listKeys(opts, cb) {
 | 
				
			||||||
    var endpoint = sprintf('/%s/keys', this.user);
 | 
					    var endpoint = format('/%s/keys', this.user);
 | 
				
			||||||
    this._passThrough(endpoint, opts, cb);
 | 
					    this._passThrough(endpoint, opts, cb);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -341,7 +340,7 @@ CloudAPI.prototype.listKeys = function listKeys(opts, cb) {
 | 
				
			|||||||
 * @param {Function} callback of the form `function (err, images, res)`
 | 
					 * @param {Function} callback of the form `function (err, images, res)`
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CloudAPI.prototype.listImages = function listImages(opts, cb) {
 | 
					CloudAPI.prototype.listImages = function listImages(opts, cb) {
 | 
				
			||||||
    var endpoint = sprintf('/%s/images', this.user);
 | 
					    var endpoint = format('/%s/images', this.user);
 | 
				
			||||||
    this._passThrough(endpoint, opts, cb);
 | 
					    this._passThrough(endpoint, opts, cb);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -372,7 +371,7 @@ CloudAPI.prototype.getImage = function getImage(options, callback) {
 | 
				
			|||||||
// ---- packages
 | 
					// ---- packages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CloudAPI.prototype.listPackages = function listPackages(opts, cb) {
 | 
					CloudAPI.prototype.listPackages = function listPackages(opts, cb) {
 | 
				
			||||||
    var endpoint = sprintf('/%s/packages', this.user);
 | 
					    var endpoint = format('/%s/packages', this.user);
 | 
				
			||||||
    this._passThrough(endpoint, opts, cb);
 | 
					    this._passThrough(endpoint, opts, cb);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -407,7 +406,7 @@ CloudAPI.prototype.getMachine = function getMachine(id, cb) {
 | 
				
			|||||||
    assert.uuid(id, 'id');
 | 
					    assert.uuid(id, 'id');
 | 
				
			||||||
    assert.func(cb, 'cb');
 | 
					    assert.func(cb, 'cb');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var endpoint = sprintf('/%s/machines/%s', this.user, id);
 | 
					    var endpoint = format('/%s/machines/%s', this.user, id);
 | 
				
			||||||
    this._request(endpoint, function (err, req, res, body) {
 | 
					    this._request(endpoint, function (err, req, res, body) {
 | 
				
			||||||
        cb(err, body, res);
 | 
					        cb(err, body, res);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -425,7 +424,7 @@ CloudAPI.prototype.deleteMachine = function deleteMachine(uuid, callback) {
 | 
				
			|||||||
    assert.func(callback, 'callback');
 | 
					    assert.func(callback, 'callback');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var opts = {
 | 
					    var opts = {
 | 
				
			||||||
        path: sprintf('/%s/machines/%s', self.user, uuid),
 | 
					        path: format('/%s/machines/%s', self.user, uuid),
 | 
				
			||||||
        method: 'DELETE'
 | 
					        method: 'DELETE'
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    this._request(opts, function (err, req, res, body) {
 | 
					    this._request(opts, function (err, req, res, body) {
 | 
				
			||||||
@ -473,7 +472,7 @@ CloudAPI.prototype._doMachine = function _doMachine(action, uuid, callback) {
 | 
				
			|||||||
    assert.func(callback, 'callback');
 | 
					    assert.func(callback, 'callback');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var opts = {
 | 
					    var opts = {
 | 
				
			||||||
        path: sprintf('/%s/machines/%s', self.user, uuid),
 | 
					        path: format('/%s/machines/%s', self.user, uuid),
 | 
				
			||||||
        method: 'POST',
 | 
					        method: 'POST',
 | 
				
			||||||
        data: {
 | 
					        data: {
 | 
				
			||||||
            action: action
 | 
					            action: action
 | 
				
			||||||
@ -620,7 +619,7 @@ CloudAPI.prototype.machineAudit = function machineAudit(options, callback) {
 | 
				
			|||||||
    assert.string(options.id, 'options.id');
 | 
					    assert.string(options.id, 'options.id');
 | 
				
			||||||
    assert.func(callback, 'callback');
 | 
					    assert.func(callback, 'callback');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var path = sprintf('/%s/machines/%s/audit', self.user, options.id);
 | 
					    var path = format('/%s/machines/%s/audit', self.user, options.id);
 | 
				
			||||||
    // XXX This `client.get` block is duplicated. Add a convenience func for it:
 | 
					    // XXX This `client.get` block is duplicated. Add a convenience func for it:
 | 
				
			||||||
    self._getAuthHeaders(function (hErr, headers) {
 | 
					    self._getAuthHeaders(function (hErr, headers) {
 | 
				
			||||||
        if (hErr) {
 | 
					        if (hErr) {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user