PUBAPI-1171 improve boolean envvar error handling

PUBAPI-1205 mirror node-smartdc meaning for SDC_TESTING
PUBAPI-1351 label each group of env vars for clarity
Reviewed by: Trent Mick <trent.mick@joyent.com>
Approved by: Trent Mick <trent.mick@joyent.com>
This commit is contained in:
Chris Burroughs 2017-01-24 10:19:48 -05:00
parent c7c91aea83
commit 68e5b68583
3 changed files with 22 additions and 8 deletions

View File

@ -7,6 +7,15 @@ Known issues:
## not yet released
- PUBAPI-1171/PUBAPI-1205/PUBAPI-1351 The handling of legacy `SDC_*`
environment variables has been cleaned up. These environment
variables are used for compatibility with the node-smartdc toolset.
* `SDC_TESTING` is now evaluated the same way as node-smartdc. Any
set value but the empty string is true.
* Errors on boolean environment variables will now identify the
variable at fault.
* `triton env` will emit additional comments grouping variables.
- [joyent/node-triton#80] Add `triton network list public=true|false`
filtering. Note that this filtering is client-side.

View File

@ -288,15 +288,16 @@ function _loadEnvProfile() {
{
return null;
}
if (process.env.TRITON_TLS_INSECURE) {
envProfile.insecure = common.boolFromString(
process.env.TRITON_TLS_INSECURE);
process.env.TRITON_TLS_INSECURE, undefined, 'TRITON_TLS_INSECURE');
} else if (process.env.SDC_TLS_INSECURE) {
envProfile.insecure = common.boolFromString(
process.env.SDC_TLS_INSECURE);
} else if (process.env.SDC_TESTING) { // deprecated
envProfile.insecure = common.boolFromString(process.env.SDC_TESTING);
process.env.SDC_TLS_INSECURE, undefined, 'SDC_TLS_INSECURE');
} else if (process.env.SDC_TESTING) {
// For compatibility with the legacy behavior of the smartdc
// tools, *any* set value but the empty string is considered true.
envProfile.insecure = true;
}
validateProfile(envProfile, 'environment variables');

View File

@ -71,6 +71,7 @@ function do_env(subcmd, opts, args, cb) {
clientTypes.forEach(function (clientType) {
switch (clientType) {
case 'triton':
p('# triton');
if (opts.unset) {
[
'TRITON_PROFILE',
@ -87,6 +88,7 @@ function do_env(subcmd, opts, args, cb) {
}
break;
case 'docker':
p('# docker');
var setupJson = path.resolve(self.configDir, 'docker',
common.profileSlug(profile), 'setup.json');
if (fs.existsSync(setupJson)) {
@ -124,6 +126,7 @@ function do_env(subcmd, opts, args, cb) {
}
break;
case 'smartdc':
p('# smartdc');
if (opts.unset) {
[
'SDC_URL',
@ -186,7 +189,8 @@ do_env.options = [
{
names: ['smartdc', 's'],
type: 'bool',
help: 'Emit environment for node-smartdc (i.e. the "SDC_*" variables).'
help: 'Emit environment for node-smartdc (i.e. the legacy ' +
'"SDC_*" variables).'
},
{
group: ''
@ -211,8 +215,8 @@ do_env.help = [
'{{usage}}',
'',
'{{options}}',
'If no options are given, environment variables are emitted for all clients.',
'If PROFILE is not given, the current profile is used.',
'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:',