diff --git a/lib/tritonapi.js b/lib/tritonapi.js index fea63d7..1d153cb 100644 --- a/lib/tritonapi.js +++ b/lib/tritonapi.js @@ -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); });