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