diff --git a/CHANGES.md b/CHANGES.md index 36548df..194bddc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,8 @@ Known issues: ## not yet released +- [joyent/node-triton#250] Avoid an error from `triton profile list` if + only *some* of the minimal `TRITON_` or `SDC_` envvars are defined. - [TRITON-401] Add `triton network` and `triton vlan` commands, for creating/changing/removing network fabrics and VLANs. - [TRITON-524] Add `triton inst get --credentials ...` option to match diff --git a/lib/config.js b/lib/config.js index fe2fda0..ea9dc36 100644 --- a/lib/config.js +++ b/lib/config.js @@ -299,12 +299,11 @@ function _loadEnvProfile(profileOverrides) { for (var attr in profileOverrides) { envProfile[attr] = profileOverrides[attr]; } + /* - * If none of the above envvars are defined, then there is no env profile. + * If missing any of the required vars, then there is no env profile. */ - if (!envProfile.account && !envProfile.user && !envProfile.url && - !envProfile.keyId) - { + if (!envProfile.account || !envProfile.url || !envProfile.keyId) { return null; } validateProfile(envProfile, 'environment variables'); @@ -366,10 +365,11 @@ function loadProfile(opts) { function loadAllProfiles(opts) { assert.string(opts.configDir, 'opts.configDir'); assert.object(opts.log, 'opts.log'); + assert.optionalObject(opts.profileOverrides, 'opts.profileOverrides'); var profiles = []; - var envProfile = _loadEnvProfile(); + var envProfile = _loadEnvProfile(opts.profileOverrides); if (envProfile) { profiles.push(envProfile); } diff --git a/lib/do_profile/do_list.js b/lib/do_profile/do_list.js index 35ece1d..c629d6a 100644 --- a/lib/do_profile/do_list.js +++ b/lib/do_profile/do_list.js @@ -31,7 +31,8 @@ function _listProfiles(cli, opts, args, cb) { try { profiles = mod_config.loadAllProfiles({ configDir: cli.configDir, - log: cli.log + log: cli.log, + profileOverrides: cli._cliOptsAsProfile() }); } catch (e) { return cb(e);