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:
parent
4921fd2e36
commit
cc07717008
13
CHANGES.md
13
CHANGES.md
@ -6,6 +6,19 @@ Known issues:
|
|||||||
|
|
||||||
## not yet released
|
## 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
|
## 6.3.0
|
||||||
|
|
||||||
- [joyent/node-triton#259] Added basic support for use of SSH bastion hosts
|
- [joyent/node-triton#259] Added basic support for use of SSH bastion hosts
|
||||||
|
@ -31,7 +31,11 @@ function do_get(subcmd, opts, args, callback) {
|
|||||||
callback(setupErr);
|
callback(setupErr);
|
||||||
return;
|
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) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
@ -56,6 +60,15 @@ do_get.options = [
|
|||||||
names: ['json', 'j'],
|
names: ['json', 'j'],
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
help: 'JSON stream output.'
|
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.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 Joyent, Inc.
|
* Copyright 2019 Joyent, Inc.
|
||||||
*
|
*
|
||||||
* `triton instance create ...`
|
* `triton instance create ...`
|
||||||
*/
|
*/
|
||||||
@ -203,6 +203,7 @@ function do_create(subcmd, opts, args, cb) {
|
|||||||
function getImg(ctx, next) {
|
function getImg(ctx, next) {
|
||||||
var _opts = {
|
var _opts = {
|
||||||
name: args[0],
|
name: args[0],
|
||||||
|
excludeInactive: true,
|
||||||
useCache: true
|
useCache: true
|
||||||
};
|
};
|
||||||
tritonapi.getImage(_opts, function (err, img) {
|
tritonapi.getImage(_opts, function (err, img) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Joyent, Inc.
|
* Copyright 2019 Joyent, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* BEGIN JSSTYLED */
|
/* 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
|
* If there is more than one image with that name, then the latest
|
||||||
* (by published_at) is returned.
|
* (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) {
|
TritonApi.prototype.getImage = function getImage(opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -700,10 +704,13 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
|
|||||||
opts = {name: opts};
|
opts = {name: opts};
|
||||||
assert.object(opts, 'opts');
|
assert.object(opts, 'opts');
|
||||||
assert.string(opts.name, 'opts.name');
|
assert.string(opts.name, 'opts.name');
|
||||||
|
assert.optionalBool(opts.excludeInactive, 'opts.excludeInactive');
|
||||||
assert.optionalBool(opts.useCache, 'opts.useCache');
|
assert.optionalBool(opts.useCache, 'opts.useCache');
|
||||||
assert.func(cb, 'cb');
|
assert.func(cb, 'cb');
|
||||||
|
|
||||||
|
var excludeInactive = Boolean(opts.excludeInactive);
|
||||||
var img;
|
var img;
|
||||||
|
|
||||||
if (common.isUUID(opts.name)) {
|
if (common.isUUID(opts.name)) {
|
||||||
vasync.pipeline({funcs: [
|
vasync.pipeline({funcs: [
|
||||||
function tryCache(_, next) {
|
function tryCache(_, next) {
|
||||||
@ -755,10 +762,8 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
|
|||||||
var version = s[1];
|
var version = s[1];
|
||||||
var nameSelector;
|
var nameSelector;
|
||||||
|
|
||||||
var listOpts = {
|
var listOpts = {};
|
||||||
// Explicitly include inactive images.
|
listOpts.state = (excludeInactive ? 'active' : 'all');
|
||||||
state: 'all'
|
|
||||||
};
|
|
||||||
if (version) {
|
if (version) {
|
||||||
nameSelector = name + '@' + version;
|
nameSelector = name + '@' + version;
|
||||||
listOpts.name = name;
|
listOpts.name = name;
|
||||||
|
@ -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": "6.3.0",
|
"version": "7.0.0",
|
||||||
"author": "Joyent (joyent.com)",
|
"author": "Joyent (joyent.com)",
|
||||||
"homepage": "https://github.com/joyent/node-triton",
|
"homepage": "https://github.com/joyent/node-triton",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Reference in New Issue
Block a user