joyent/node-triton#250 triton profile list doesn't seem to work without full env

Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Pedro Palazón Candel <pedro@joyent.com>
Approved by: Marsell Kukuljevic <marsell@joyent.com>
Approved by: Pedro Palazón Candel <pedro@joyent.com>
This commit is contained in:
Trent Mick 2018-06-26 16:57:15 -07:00
parent 3584c82e05
commit 264f69dc54
3 changed files with 9 additions and 6 deletions

View File

@ -6,6 +6,8 @@ Known issues:
## not yet released ## 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 - [TRITON-401] Add `triton network` and `triton vlan` commands, for
creating/changing/removing network fabrics and VLANs. creating/changing/removing network fabrics and VLANs.
- [TRITON-524] Add `triton inst get --credentials ...` option to match - [TRITON-524] Add `triton inst get --credentials ...` option to match

View File

@ -299,12 +299,11 @@ function _loadEnvProfile(profileOverrides) {
for (var attr in profileOverrides) { for (var attr in profileOverrides) {
envProfile[attr] = profileOverrides[attr]; 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 && if (!envProfile.account || !envProfile.url || !envProfile.keyId) {
!envProfile.keyId)
{
return null; return null;
} }
validateProfile(envProfile, 'environment variables'); validateProfile(envProfile, 'environment variables');
@ -366,10 +365,11 @@ function loadProfile(opts) {
function loadAllProfiles(opts) { function loadAllProfiles(opts) {
assert.string(opts.configDir, 'opts.configDir'); assert.string(opts.configDir, 'opts.configDir');
assert.object(opts.log, 'opts.log'); assert.object(opts.log, 'opts.log');
assert.optionalObject(opts.profileOverrides, 'opts.profileOverrides');
var profiles = []; var profiles = [];
var envProfile = _loadEnvProfile(); var envProfile = _loadEnvProfile(opts.profileOverrides);
if (envProfile) { if (envProfile) {
profiles.push(envProfile); profiles.push(envProfile);
} }

View File

@ -31,7 +31,8 @@ function _listProfiles(cli, opts, args, cb) {
try { try {
profiles = mod_config.loadAllProfiles({ profiles = mod_config.loadAllProfiles({
configDir: cli.configDir, configDir: cli.configDir,
log: cli.log log: cli.log,
profileOverrides: cli._cliOptsAsProfile()
}); });
} catch (e) { } catch (e) {
return cb(e); return cb(e);