joyent/node-triton#111 want triton env --unset,-u
option emit env to unset relevant envvars
This commit is contained in:
parent
de391bf013
commit
a48d7629dd
@ -5,9 +5,11 @@ Known issues:
|
||||
- `triton ssh ...` disables ssh ControlMaster to avoid issue #52.
|
||||
|
||||
|
||||
## 4.10.1 (not yet released)
|
||||
## 4.11.0 (not yet released)
|
||||
|
||||
(nothing yet)
|
||||
- [#111] `triton env --unset,-u` option to emit environment commands to *unset*
|
||||
relevant envvars.
|
||||
- Unhide `triton env` from `triton --help` output.
|
||||
|
||||
|
||||
## 4.10.0
|
||||
|
7
TODO.txt
7
TODO.txt
@ -1,9 +1,4 @@
|
||||
test suite:
|
||||
- all the commands: test/integration/cli-*.test.js
|
||||
- TritonApi testing: test/integration/api-*.test.js
|
||||
- more test/unit/...
|
||||
|
||||
sub-user support (profiles, `triton account`, env, auth)
|
||||
triton create affinity support for tag matching, globs, regex
|
||||
|
||||
note in README that full UUIDs is much faster in the API
|
||||
|
||||
|
@ -207,8 +207,9 @@ function CLI() {
|
||||
},
|
||||
helpSubcmds: [
|
||||
'help',
|
||||
'completion',
|
||||
'profile',
|
||||
'env',
|
||||
'completion',
|
||||
{ group: 'Instances (aka VMs/Machines/Containers)' },
|
||||
'instance',
|
||||
'instances',
|
||||
|
@ -45,6 +45,9 @@ function do_env(subcmd, opts, args, cb) {
|
||||
shortOpts += 's';
|
||||
clientTypes.push('smartdc');
|
||||
}
|
||||
if (opts.unset) {
|
||||
shortOpts += 'u';
|
||||
}
|
||||
if (clientTypes.length === 0) {
|
||||
explicit = false;
|
||||
clientTypes = allClientTypes;
|
||||
@ -68,7 +71,20 @@ function do_env(subcmd, opts, args, cb) {
|
||||
clientTypes.forEach(function (clientType) {
|
||||
switch (clientType) {
|
||||
case 'triton':
|
||||
if (opts.unset) {
|
||||
[
|
||||
'TRITON_PROFILE',
|
||||
'TRITON_URL',
|
||||
'TRITON_ACCOUNT',
|
||||
'TRITON_USER',
|
||||
'TRITON_KEY_ID',
|
||||
'TRITON_TLS_INSECURE'
|
||||
].forEach(function (key) {
|
||||
p('unset %s', key);
|
||||
});
|
||||
} else {
|
||||
p('export TRITON_PROFILE="%s"', profile.name);
|
||||
}
|
||||
break;
|
||||
case 'docker':
|
||||
var setupJson = path.resolve(self.configDir, 'docker',
|
||||
@ -85,12 +101,21 @@ function do_env(subcmd, opts, args, cb) {
|
||||
}
|
||||
Object.keys(setup.env).forEach(function (key) {
|
||||
var val = setup.env[key];
|
||||
if (val === null) {
|
||||
if (opts.unset || val === null) {
|
||||
p('unset %s', key);
|
||||
} else {
|
||||
p('export %s=%s', key, val);
|
||||
}
|
||||
});
|
||||
} else if (opts.unset) {
|
||||
[
|
||||
'DOCKER_HOST',
|
||||
'DOCKER_CERT_PATH',
|
||||
'DOCKER_TLS_VERIFY',
|
||||
'COMPOSE_HTTP_TIMEOUT'
|
||||
].forEach(function (key) {
|
||||
p('unset %s', key);
|
||||
});
|
||||
} else if (explicit) {
|
||||
cb(new errors.ConfigError(format('could not find Docker '
|
||||
+ 'environment setup for profile "%s":\n Run `triton '
|
||||
@ -99,6 +124,17 @@ function do_env(subcmd, opts, args, cb) {
|
||||
}
|
||||
break;
|
||||
case 'smartdc':
|
||||
if (opts.unset) {
|
||||
[
|
||||
'SDC_URL',
|
||||
'SDC_ACCOUNT',
|
||||
'SDC_USER',
|
||||
'SDC_KEY_ID',
|
||||
'SDC_TESTING'
|
||||
].forEach(function (key) {
|
||||
p('unset %s', key);
|
||||
});
|
||||
} else {
|
||||
p('export SDC_URL="%s"', profile.url);
|
||||
p('export SDC_ACCOUNT="%s"', profile.account);
|
||||
if (profile.user) {
|
||||
@ -112,6 +148,7 @@ function do_env(subcmd, opts, args, cb) {
|
||||
} else {
|
||||
p('unset SDC_TESTING');
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return cb(new errors.InternalError(
|
||||
@ -132,6 +169,9 @@ do_env.options = [
|
||||
type: 'bool',
|
||||
help: 'Show this help.'
|
||||
},
|
||||
{
|
||||
group: ''
|
||||
},
|
||||
{
|
||||
names: ['triton', 't'],
|
||||
type: 'bool',
|
||||
@ -147,13 +187,21 @@ do_env.options = [
|
||||
names: ['smartdc', 's'],
|
||||
type: 'bool',
|
||||
help: 'Emit environment for node-smartdc (i.e. the "SDC_*" variables).'
|
||||
},
|
||||
{
|
||||
group: ''
|
||||
},
|
||||
{
|
||||
names: ['unset', 'u'],
|
||||
type: 'bool',
|
||||
help: 'Emit environment to *unset* the relevant environment variables.'
|
||||
}
|
||||
];
|
||||
|
||||
// TODO: support env for docker usage.
|
||||
do_env.help = [
|
||||
/* BEGIN JSSTYLED */
|
||||
'Emit shell environment commands to setup clients for a particular CLI profile.',
|
||||
'Emit shell commands to setup environment.',
|
||||
'',
|
||||
'Supported "clients" here are: node-smartdc (i.e. the `sdc-*` tools),',
|
||||
'and node-triton itself. By default this emits the environment for all',
|
||||
@ -162,11 +210,21 @@ do_env.help = [
|
||||
'Usage:',
|
||||
' {{name}} env [PROFILE]',
|
||||
'',
|
||||
'{{options}}'
|
||||
'{{options}}',
|
||||
'If no options are given, environment variables are emitted for all clients.',
|
||||
'If PROFILE is not given, the current profile is used.',
|
||||
'',
|
||||
'The following Bash function can be added to one\'s "~/.bashrc" to quickly',
|
||||
'change between Triton profiles:',
|
||||
' triton-select () { eval "$(triton env $1)"; }',
|
||||
'for example:',
|
||||
' $ triton-select west1',
|
||||
' $ triton profile get | grep name',
|
||||
' name: west1',
|
||||
' $ triton-select east1',
|
||||
' $ triton profile get | grep name',
|
||||
' name: east1'
|
||||
/* END JSSTYLED */
|
||||
].join('\n');
|
||||
|
||||
|
||||
do_env.hidden = true;
|
||||
|
||||
module.exports = do_env;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "triton",
|
||||
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
|
||||
"version": "4.10.1",
|
||||
"version": "4.11.0",
|
||||
"author": "Joyent (joyent.com)",
|
||||
"dependencies": {
|
||||
"assert-plus": "0.2.0",
|
||||
|
@ -28,6 +28,8 @@ var subs = [
|
||||
['profile create'],
|
||||
['profile edit'],
|
||||
['profile delete', 'profile rm'],
|
||||
['env'],
|
||||
['completion'],
|
||||
['account'],
|
||||
['account get'],
|
||||
['account update'],
|
||||
|
Reference in New Issue
Block a user