joyent/node-triton#258 triton instance create picks disabled image

Reviewed by: Brian Bennett <brian.bennett@joyent.com>
Approved by: Brian Bennett <brian.bennett@joyent.com>
This commit is contained in:
Trent Mick 2019-03-06 17:25:00 -08:00
parent 4921fd2e36
commit cc07717008
5 changed files with 40 additions and 8 deletions

View File

@ -6,6 +6,19 @@ Known issues:
## not yet released
(nothing)
## 7.0.0
- [Backward incompatible.] `triton image get NAME|SHORTID` will now *exclude*
inactive images by default. Before this change inactive images (e.g. those
with a state of "creating" or "unactivated" or "disabled") would be
included. Use the new `-a,--all` option to include inactive images. This
matches the behavior of `triton image list [-a,--all] ...`.
- [joyent/node-triton#258] `triton instance create IMAGE ...` will now exclude
inactive images when looking for an image with the given name.
## 6.3.0
- [joyent/node-triton#259] Added basic support for use of SSH bastion hosts

View File

@ -31,7 +31,11 @@ function do_get(subcmd, opts, args, callback) {
callback(setupErr);
return;
}
tritonapi.getImage(args[0], function onRes(err, img) {
var getOpts = {
name: args[0],
excludeInactive: !opts.all
};
tritonapi.getImage(getOpts, function onRes(err, img) {
if (err) {
return callback(err);
}
@ -56,6 +60,15 @@ do_get.options = [
names: ['json', 'j'],
type: 'bool',
help: 'JSON stream output.'
},
{
group: 'Filtering options'
},
{
names: ['all', 'a'],
type: 'bool',
help: 'Include all images when matching by name or short ID, not ' +
'just "active" ones. By default only active images are included.'
}
];

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright 2018 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*
* `triton instance create ...`
*/
@ -203,6 +203,7 @@ function do_create(subcmd, opts, args, cb) {
function getImg(ctx, next) {
var _opts = {
name: args[0],
excludeInactive: true,
useCache: true
};
tritonapi.getImage(_opts, function (err, img) {

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/
/* BEGIN JSSTYLED */
@ -693,6 +693,10 @@ TritonApi.prototype.listImages = function listImages(opts, cb) {
*
* If there is more than one image with that name, then the latest
* (by published_at) is returned.
*
* @param {Boolean} opts.excludeInactive - Exclude inactive images when
* matching. By default inactive images are included. This param is *not*
* used when a full image ID (a UUID) is given.
*/
TritonApi.prototype.getImage = function getImage(opts, cb) {
var self = this;
@ -700,10 +704,13 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
opts = {name: opts};
assert.object(opts, 'opts');
assert.string(opts.name, 'opts.name');
assert.optionalBool(opts.excludeInactive, 'opts.excludeInactive');
assert.optionalBool(opts.useCache, 'opts.useCache');
assert.func(cb, 'cb');
var excludeInactive = Boolean(opts.excludeInactive);
var img;
if (common.isUUID(opts.name)) {
vasync.pipeline({funcs: [
function tryCache(_, next) {
@ -755,10 +762,8 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
var version = s[1];
var nameSelector;
var listOpts = {
// Explicitly include inactive images.
state: 'all'
};
var listOpts = {};
listOpts.state = (excludeInactive ? 'active' : 'all');
if (version) {
nameSelector = name + '@' + version;
listOpts.name = name;

View File

@ -1,7 +1,7 @@
{
"name": "triton",
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
"version": "6.3.0",
"version": "7.0.0",
"author": "Joyent (joyent.com)",
"homepage": "https://github.com/joyent/node-triton",
"dependencies": {