joyent/node-triton#130 triton image caching should include disabled images

Reviewed by: Cody Peter Mello <cody.mello@joyent.com>
Approved by: Cody Peter Mello <cody.mello@joyent.com>
This commit is contained in:
Trent Mick 2016-09-16 16:01:38 -07:00
parent c7f7f86126
commit 21f2d29c86
5 changed files with 18 additions and 12 deletions

View File

@ -5,9 +5,10 @@ Known issues:
- `triton ssh ...` disables ssh ControlMaster to avoid issue #52. - `triton ssh ...` disables ssh ControlMaster to avoid issue #52.
## 4.13.1 (not yet released) ## 4.14.0 (not yet released)
(nothing yet) - [#130] Include disabled images when using an image cache (e.g. for filling in
image name and version details in `triton ls` output.
## 4.13.0 ## 4.13.0

View File

@ -56,8 +56,10 @@ function do_instances(subcmd, opts, args, cb) {
vasync.parallel({funcs: [ vasync.parallel({funcs: [
function getTheImages(next) { function getTheImages(next) {
tritonapi.listImages({useCache: true}, tritonapi.listImages({
function (err, _imgs) { useCache: true,
state: 'all'
}, function (err, _imgs) {
if (err) { if (err) {
next(err); next(err);
} else { } else {

View File

@ -76,8 +76,10 @@ function do_list(subcmd, opts, args, callback) {
vasync.parallel({funcs: [ vasync.parallel({funcs: [
function getTheImages(next) { function getTheImages(next) {
self.top.tritonapi.listImages({useCache: true}, self.top.tritonapi.listImages({
function (err, _imgs) { state: 'all',
useCache: true
}, function (err, _imgs) {
if (err) { if (err) {
if (err.statusCode === 403) { if (err.statusCode === 403) {
/* /*

View File

@ -282,8 +282,9 @@ TritonApi.prototype._cacheGetJson = function _cacheGetJson(key, cb) {
* *
* @param opts {Object} Optional. * @param opts {Object} Optional.
* - useCache {Boolean} Default false. Whether to use Triton's local cache. * - useCache {Boolean} Default false. Whether to use Triton's local cache.
* Note that the *current* implementation will only use the cache * Currently the cache is only used and updated if the filters are
* when there are no filter options. * exactly `{state: "all"}`. IOW, the ListImages call that returns
* all visible images.
* - ... all other cloudapi ListImages options per * - ... all other cloudapi ListImages options per
* <https://apidocs.joyent.com/cloudapi/#ListImages> * <https://apidocs.joyent.com/cloudapi/#ListImages>
* @param {Function} callback `function (err, imgs)` * @param {Function} callback `function (err, imgs)`
@ -304,10 +305,10 @@ TritonApi.prototype.listImages = function listImages(opts, cb) {
// For now at least, we only cache full results (no filtering). // For now at least, we only cache full results (no filtering).
var useCache = Boolean(opts.useCache); var useCache = Boolean(opts.useCache);
var cacheKey; var cacheKey;
if (Object.keys(listOpts).length > 0) { if (Object.keys(listOpts).length === 1 && listOpts.state === 'all') {
useCache = false;
} else {
cacheKey = 'images.json'; cacheKey = 'images.json';
} else {
useCache = false;
} }
var cached; var cached;
var fetched; var fetched;

View File

@ -1,7 +1,7 @@
{ {
"name": "triton", "name": "triton",
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)", "description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
"version": "4.13.1", "version": "4.14.0",
"author": "Joyent (joyent.com)", "author": "Joyent (joyent.com)",
"dependencies": { "dependencies": {
"assert-plus": "0.2.0", "assert-plus": "0.2.0",