'triton --accept-version VER ...' developer option
This commit is contained in:
parent
48b6be58f4
commit
3cd4b0d735
@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
## 3.1.1 (not yet released)
|
## 3.1.1 (not yet released)
|
||||||
|
|
||||||
(nothing yet)
|
- `triton --accept-version VER` hidden top-level option for development. This
|
||||||
|
allows calling the target cloudapi with the given value for the
|
||||||
|
"Accept-Version" header -- which is how CloudAPI does API versioning.
|
||||||
|
By default `triton` is coded to a particular cloudapi version range, so
|
||||||
|
forcing a different version *could* result in breaking in the triton client
|
||||||
|
code that handles the response. IOW, this is just a tool for developers
|
||||||
|
of this Triton client and CloudAPI itself.
|
||||||
|
|
||||||
|
|
||||||
## 3.1.0
|
## 3.1.0
|
||||||
|
27
lib/cli.js
27
lib/cli.js
@ -104,7 +104,7 @@ var OPTIONS = [
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
help: 'SSH key fingerprint. Environment: TRITON_KEY_ID=FINGERPRINT ' +
|
help: 'SSH key fingerprint. Environment: TRITON_KEY_ID=FINGERPRINT ' +
|
||||||
'or SDC_KEY_ID=FINGERPRINT.',
|
'or SDC_KEY_ID=FINGERPRINT.',
|
||||||
helpArg: 'FINGERPRINT'
|
helpArg: 'FP'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ['url', 'U'],
|
names: ['url', 'U'],
|
||||||
@ -127,6 +127,18 @@ var OPTIONS = [
|
|||||||
'TRITON_TLS_INSECURE=1, SDC_TLS_INSECURE=1 (or the deprecated ' +
|
'TRITON_TLS_INSECURE=1, SDC_TLS_INSECURE=1 (or the deprecated ' +
|
||||||
'SDC_TESTING=1).',
|
'SDC_TESTING=1).',
|
||||||
'default': false
|
'default': false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ['accept-version'],
|
||||||
|
type: 'string',
|
||||||
|
helpArg: 'VER',
|
||||||
|
help: 'A cloudapi API version, or semver range, to attempt to use. ' +
|
||||||
|
'This is passed in the "Accept-Version" header. ' +
|
||||||
|
'See `triton cloudapi /--ping` to list supported versions. ' +
|
||||||
|
'The default is "' + tritonapi.CLOUDAPI_ACCEPT_VERSION + '". ' +
|
||||||
|
'*This is intended for development use only. It could cause ' +
|
||||||
|
'`triton` processing of responses to break.*',
|
||||||
|
hidden: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -253,13 +265,20 @@ CLI.prototype.init = function (opts, args, callback) {
|
|||||||
CLI.prototype._applyProfileOverrides =
|
CLI.prototype._applyProfileOverrides =
|
||||||
function _applyProfileOverrides(profile) {
|
function _applyProfileOverrides(profile) {
|
||||||
var self = this;
|
var self = this;
|
||||||
['account', 'user', 'url', 'keyId', 'insecure'].forEach(function (field) {
|
[
|
||||||
|
{oname: 'account', pname: 'account'},
|
||||||
|
{oname: 'user', pname: 'user'},
|
||||||
|
{oname: 'url', pname: 'url'},
|
||||||
|
{oname: 'keyId', pname: 'keyId'},
|
||||||
|
{oname: 'insecure', pname: 'insecure'},
|
||||||
|
{oname: 'accept_version', pname: 'acceptVersion'}
|
||||||
|
].forEach(function (field) {
|
||||||
// We need to check `opts._order` to know if boolean opts
|
// We need to check `opts._order` to know if boolean opts
|
||||||
// were specified.
|
// were specified.
|
||||||
var specified = self.opts._order.filter(
|
var specified = self.opts._order.filter(
|
||||||
function (opt) { return opt.key === field; }).length > 0;
|
function (opt) { return opt.key === field.oname; }).length > 0;
|
||||||
if (specified) {
|
if (specified) {
|
||||||
profile[field] = self.opts[field];
|
profile[field.pname] = self.opts[field.oname];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,11 @@ var errors = require('./errors');
|
|||||||
var loadConfigSync = require('./config').loadConfigSync;
|
var loadConfigSync = require('./config').loadConfigSync;
|
||||||
|
|
||||||
|
|
||||||
|
// ---- globals
|
||||||
|
|
||||||
|
var CLOUDAPI_ACCEPT_VERSION = '~8||~7';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---- internal support stuff
|
// ---- internal support stuff
|
||||||
|
|
||||||
@ -117,8 +122,11 @@ TritonApi.prototype._cloudapiFromProfile =
|
|||||||
assert.optionalString(profile.user, 'profile.user');
|
assert.optionalString(profile.user, 'profile.user');
|
||||||
assert.optionalString(profile.privKey, 'profile.privKey');
|
assert.optionalString(profile.privKey, 'profile.privKey');
|
||||||
assert.optionalBool(profile.insecure, 'profile.insecure');
|
assert.optionalBool(profile.insecure, 'profile.insecure');
|
||||||
|
assert.optionalString(profile.acceptVersion, 'profile.acceptVersion');
|
||||||
|
|
||||||
var rejectUnauthorized = (profile.insecure === undefined
|
var rejectUnauthorized = (profile.insecure === undefined
|
||||||
? true : !profile.insecure);
|
? true : !profile.insecure);
|
||||||
|
var acceptVersion = profile.acceptVersion || CLOUDAPI_ACCEPT_VERSION;
|
||||||
|
|
||||||
var sign;
|
var sign;
|
||||||
if (profile.privKey) {
|
if (profile.privKey) {
|
||||||
@ -139,7 +147,7 @@ TritonApi.prototype._cloudapiFromProfile =
|
|||||||
url: profile.url,
|
url: profile.url,
|
||||||
account: profile.account,
|
account: profile.account,
|
||||||
user: profile.user,
|
user: profile.user,
|
||||||
version: '*',
|
version: acceptVersion,
|
||||||
rejectUnauthorized: rejectUnauthorized,
|
rejectUnauthorized: rejectUnauthorized,
|
||||||
sign: sign,
|
sign: sign,
|
||||||
log: this.log
|
log: this.log
|
||||||
@ -933,6 +941,9 @@ TritonApi.prototype.deletePolicy = function deletePolicy(opts, cb) {
|
|||||||
|
|
||||||
//---- exports
|
//---- exports
|
||||||
|
|
||||||
module.exports.createClient = function (options) {
|
module.exports = {
|
||||||
return new TritonApi(options);
|
CLOUDAPI_ACCEPT_VERSION: CLOUDAPI_ACCEPT_VERSION,
|
||||||
|
createClient: function createClient(opts) {
|
||||||
|
return new TritonApi(opts);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user