add 'triton env -t'
This commit is contained in:
parent
91ca036fbe
commit
9fbb2006bc
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
## 4.0.1 (not yet released)
|
## 4.0.1 (not yet released)
|
||||||
|
|
||||||
(nothing yet)
|
- Add `triton env -t` to be able to emit a shell environment to configure `triton` itself.
|
||||||
|
This allows one to have the following Bash function to select a Triton profile for
|
||||||
|
`triton` and node-smartdc tooling:
|
||||||
|
|
||||||
|
function triton-select { eval $(triton env $1); }
|
||||||
|
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
|
@ -28,9 +28,16 @@ function do_env(subcmd, opts, args, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var profileName = args[0] || this.tritonapi.profile.name;
|
var profileName = args[0] || this.tritonapi.profile.name;
|
||||||
var clientType = 'smartdc';
|
var allClientTypes = ['smartdc', 'triton'];
|
||||||
|
var clientTypes = [];
|
||||||
if (opts.smartdc) {
|
if (opts.smartdc) {
|
||||||
clientType = 'smartdc';
|
clientTypes.push('smartdc');
|
||||||
|
}
|
||||||
|
if (opts.triton) {
|
||||||
|
clientTypes.push('triton');
|
||||||
|
}
|
||||||
|
if (clientTypes.length === 0) {
|
||||||
|
clientTypes = allClientTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -46,28 +53,38 @@ function do_env(subcmd, opts, args, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var p = console.log;
|
var p = console.log;
|
||||||
switch (clientType) {
|
var shortOpts = '';
|
||||||
case 'smartdc':
|
clientTypes.forEach(function (clientType) {
|
||||||
p('export SDC_URL="%s"', profile.url);
|
switch (clientType) {
|
||||||
p('export SDC_ACCOUNT="%s"', profile.account);
|
case 'triton':
|
||||||
if (profile.user) {
|
shortOpts += 't';
|
||||||
p('export SDC_USER="%s"', profile.user);
|
p('export TRITON_PROFILE="%s"', profile.name);
|
||||||
} else {
|
break;
|
||||||
p('unset SDC_USER');
|
case 'smartdc':
|
||||||
|
shortOpts += 's';
|
||||||
|
p('export SDC_URL="%s"', profile.url);
|
||||||
|
p('export SDC_ACCOUNT="%s"', profile.account);
|
||||||
|
if (profile.user) {
|
||||||
|
p('export SDC_USER="%s"', profile.user);
|
||||||
|
} else {
|
||||||
|
p('unset SDC_USER');
|
||||||
|
}
|
||||||
|
p('export SDC_KEY_ID="%s"', profile.keyId);
|
||||||
|
if (profile.insecure) {
|
||||||
|
p('export SDC_TESTING="%s"', profile.insecure);
|
||||||
|
} else {
|
||||||
|
p('unset SDC_TESTING');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return cb(new errors.InternalError(
|
||||||
|
'unknown clientType: ' + clientType));
|
||||||
}
|
}
|
||||||
p('export SDC_KEY_ID="%s"', profile.keyId);
|
});
|
||||||
if (profile.insecure) {
|
|
||||||
p('export SDC_TESTING="%s"', profile.insecure);
|
p('# Run this command to configure your shell:');
|
||||||
} else {
|
p('# eval "$(triton env%s %s)"',
|
||||||
p('unset SDC_TESTING');
|
(shortOpts ? ' -'+shortOpts : ''), profile.name);
|
||||||
}
|
|
||||||
p('# Run this command to configure your shell:');
|
|
||||||
p('# eval "$(triton env -s %s)"', profile.name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return cb(new errors.InternalError(
|
|
||||||
'unknown clientType: ' + clientType));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_env.options = [
|
do_env.options = [
|
||||||
@ -79,20 +96,24 @@ do_env.options = [
|
|||||||
{
|
{
|
||||||
names: ['smartdc', 's'],
|
names: ['smartdc', 's'],
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
help: 'Emit environment commands for node-smartdc.'
|
help: 'Emit environment for node-smartdc (i.e. the "SDC_*" variables).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ['triton', 't'],
|
||||||
|
type: 'bool',
|
||||||
|
help: 'Emit environment commands for node-triton itself (i.e. the ' +
|
||||||
|
'"TRITON_PROFILE" variable).'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// TODO: support env for docker usage.
|
||||||
do_env.help = [
|
do_env.help = [
|
||||||
/* BEGIN JSSTYLED */
|
/* BEGIN JSSTYLED */
|
||||||
'Emit shell environment commands to setup clients for a particular CLI profile.',
|
'Emit shell environment commands to setup clients for a particular CLI profile.',
|
||||||
'',
|
'',
|
||||||
'Supported "clients" here are: node-smartdc (the `sdc-*` tools).',
|
'Supported "clients" here are: node-smartdc (i.e. the `sdc-*` tools),',
|
||||||
'TODO: support for `triton` and `docker`.',
|
'and node-triton itself. By default this emits the environment for all',
|
||||||
'',
|
'supported tools. Use options to be specific.',
|
||||||
'Note: By default this *currently* emits the environment for node-smartdc.',
|
|
||||||
'However, automated usage should use `-s` to guaratee that. The default',
|
|
||||||
'might change',
|
|
||||||
'',
|
'',
|
||||||
'Usage:',
|
'Usage:',
|
||||||
' {{name}} env [PROFILE]',
|
' {{name}} env [PROFILE]',
|
||||||
|
@ -370,6 +370,7 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
|
|||||||
if (version) {
|
if (version) {
|
||||||
listOpts.name = name;
|
listOpts.name = name;
|
||||||
listOpts.version = version;
|
listOpts.version = version;
|
||||||
|
// XXX This is bogus now?
|
||||||
listOpts.useCache = opts.useCache;
|
listOpts.useCache = opts.useCache;
|
||||||
}
|
}
|
||||||
this.cloudapi.listImages(listOpts, function (err, imgs) {
|
this.cloudapi.listImages(listOpts, function (err, imgs) {
|
||||||
|
Reference in New Issue
Block a user