fix 'name' var usage; style nit on for-loop usage for early out

This commit is contained in:
Trent Mick 2015-10-06 23:33:18 -07:00
parent b73766d399
commit a71a1ddba3

View File

@ -275,11 +275,12 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
next(err); next(err);
return; return;
} }
var _img = images.filter(function (i) { for (var i = 0; i < images.length; i++) {
return i.id === opts.name; if (images[i].id === opts.name) {
}); img = images[i];
if (_img.length === 1) break;
img = _img[0]; }
}
next(); next();
}); });
}, },
@ -291,8 +292,8 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
self.cloudapi.getImage({id: opts.name}, function (err, img_) { self.cloudapi.getImage({id: opts.name}, function (err, img_) {
img = img_; img = img_;
if (err && err.restCode === 'ResourceNotFound') { if (err && err.restCode === 'ResourceNotFound') {
err = new errors.ResourceNotFoundError(err, err = new errors.ResourceNotFoundError(err, format(
format('image with id %s was not found', name)); 'image with id %s was not found', opts.name));
} }
next(err); next(err);
}); });