add 'triton env -t'
This commit is contained in:
parent
91ca036fbe
commit
9fbb2006bc
@ -2,7 +2,11 @@
|
||||
|
||||
## 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
|
||||
|
@ -28,9 +28,16 @@ function do_env(subcmd, opts, args, cb) {
|
||||
}
|
||||
|
||||
var profileName = args[0] || this.tritonapi.profile.name;
|
||||
var clientType = 'smartdc';
|
||||
var allClientTypes = ['smartdc', 'triton'];
|
||||
var clientTypes = [];
|
||||
if (opts.smartdc) {
|
||||
clientType = 'smartdc';
|
||||
clientTypes.push('smartdc');
|
||||
}
|
||||
if (opts.triton) {
|
||||
clientTypes.push('triton');
|
||||
}
|
||||
if (clientTypes.length === 0) {
|
||||
clientTypes = allClientTypes;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -46,8 +53,15 @@ function do_env(subcmd, opts, args, cb) {
|
||||
}
|
||||
|
||||
var p = console.log;
|
||||
var shortOpts = '';
|
||||
clientTypes.forEach(function (clientType) {
|
||||
switch (clientType) {
|
||||
case 'triton':
|
||||
shortOpts += 't';
|
||||
p('export TRITON_PROFILE="%s"', profile.name);
|
||||
break;
|
||||
case 'smartdc':
|
||||
shortOpts += 's';
|
||||
p('export SDC_URL="%s"', profile.url);
|
||||
p('export SDC_ACCOUNT="%s"', profile.account);
|
||||
if (profile.user) {
|
||||
@ -61,13 +75,16 @@ function do_env(subcmd, opts, args, cb) {
|
||||
} else {
|
||||
p('unset SDC_TESTING');
|
||||
}
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
p('# Run this command to configure your shell:');
|
||||
p('# eval "$(triton env%s %s)"',
|
||||
(shortOpts ? ' -'+shortOpts : ''), profile.name);
|
||||
}
|
||||
|
||||
do_env.options = [
|
||||
@ -79,20 +96,24 @@ do_env.options = [
|
||||
{
|
||||
names: ['smartdc', 's'],
|
||||
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 = [
|
||||
/* BEGIN JSSTYLED */
|
||||
'Emit shell environment commands to setup clients for a particular CLI profile.',
|
||||
'',
|
||||
'Supported "clients" here are: node-smartdc (the `sdc-*` tools).',
|
||||
'TODO: support for `triton` and `docker`.',
|
||||
'',
|
||||
'Note: By default this *currently* emits the environment for node-smartdc.',
|
||||
'However, automated usage should use `-s` to guaratee that. The default',
|
||||
'might change',
|
||||
'Supported "clients" here are: node-smartdc (i.e. the `sdc-*` tools),',
|
||||
'and node-triton itself. By default this emits the environment for all',
|
||||
'supported tools. Use options to be specific.',
|
||||
'',
|
||||
'Usage:',
|
||||
' {{name}} env [PROFILE]',
|
||||
|
@ -370,6 +370,7 @@ TritonApi.prototype.getImage = function getImage(opts, cb) {
|
||||
if (version) {
|
||||
listOpts.name = name;
|
||||
listOpts.version = version;
|
||||
// XXX This is bogus now?
|
||||
listOpts.useCache = opts.useCache;
|
||||
}
|
||||
this.cloudapi.listImages(listOpts, function (err, imgs) {
|
||||
|
Reference in New Issue
Block a user