Fix handling of SDC_TESTING envvar
This commit is contained in:
parent
5e3efa02a6
commit
1b2ed0758e
@ -198,8 +198,12 @@ CLI.prototype.init = function (opts, args, callback) {
|
|||||||
keyId: opts.keyId,
|
keyId: opts.keyId,
|
||||||
insecure: opts.insecure
|
insecure: opts.insecure
|
||||||
};
|
};
|
||||||
if (opts.insecure === undefined && process.env.SDC_TESTING) {
|
// If --insecure not given, look at envvar(s) for that.
|
||||||
opts.insecure = common.boolFromString(process.env.SDC_TESTING);
|
var specifiedInsecureOpt = opts._order.filter(
|
||||||
|
function (opt) { return opt.key === 'insecure'; }).length > 0;
|
||||||
|
if (!specifiedInsecureOpt && process.env.SDC_TESTING) {
|
||||||
|
opts.insecure = common.boolFromString(process.env.SDC_TESTING,
|
||||||
|
false, '"SDC_TESTING" envvar');
|
||||||
}
|
}
|
||||||
if (opts.J) {
|
if (opts.J) {
|
||||||
envProfile.url = format('https://%s.api.joyent.com', opts.J);
|
envProfile.url = format('https://%s.api.joyent.com', opts.J);
|
||||||
|
@ -50,7 +50,7 @@ function zeroPad(n, width) {
|
|||||||
*
|
*
|
||||||
* @param value {Boolean|String} The input value to convert.
|
* @param value {Boolean|String} The input value to convert.
|
||||||
* @param default_ {Boolean} The default value is `value` is undefined.
|
* @param default_ {Boolean} The default value is `value` is undefined.
|
||||||
* @param errName {String} The variable name to quote in the possibly
|
* @param errName {String} The context to quote in the possibly
|
||||||
* raised TypeError.
|
* raised TypeError.
|
||||||
*/
|
*/
|
||||||
function boolFromString(value, default_, errName) {
|
function boolFromString(value, default_, errName) {
|
||||||
@ -63,8 +63,11 @@ function boolFromString(value, default_, errName) {
|
|||||||
} else if (typeof (value) === 'boolean') {
|
} else if (typeof (value) === 'boolean') {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError(
|
var errmsg = format('invalid boolean value: %j', value);
|
||||||
format('invalid value for "%s": %j', errName, value));
|
if (errName) {
|
||||||
|
errmsg = format('invalid boolean value for %s: %j', errName, value);
|
||||||
|
}
|
||||||
|
throw new TypeError(errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user