@axway/axway-central-cli 2.5.3 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/commands/get/index.js +12 -16
- package/dist/commands/install/helpers/index.js +4 -4
- package/dist/commands/install/helpers/inputs.js +1 -1
- package/dist/commands/install/helpers/templates/edgeTemplates.js +6 -6
- package/dist/commands/install/istioAgents.js +1 -1
- package/dist/commands/install/platform.js +9 -5
- package/dist/common/ApiServerClient.js +19 -8
- package/dist/common/CoreConfigController.js +65 -66
- package/dist/common/PlatformClient.js +18 -27
- package/dist/common/dataService.js +20 -2
- package/dist/common/types.js +6 -4
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Axway Central CLI package for managing Amplify Central resources and DevOps operations.
|
|
4
4
|
|
|
5
|
-
**For more documentation and examples please visit [Amplify Central CLI documentation portal](https://docs.axway.com/bundle/
|
|
5
|
+
**For more documentation and examples please visit [Amplify Central CLI documentation portal](https://docs.axway.com/bundle/amplify-central/page/docs/integrate_with_central/cli_central/index.html).**
|
|
6
6
|
|
|
7
7
|
# Installation
|
|
8
8
|
|
|
@@ -250,7 +250,7 @@ PROXIES OPTIONS:
|
|
|
250
250
|
--json Show JSON output
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
-
CLI supports multiple versions of proxy definition file. For more details and examples visit our [docs portal](https://docs.axway.com/bundle/
|
|
253
|
+
CLI supports multiple versions of proxy definition file. For more details and examples visit our [docs portal](https://docs.axway.com/bundle/amplify-central/page/docs/integrate_with_central/cli_central/index.html) and [stoplight hub](https://d-api.docs.stoplight.io/).
|
|
254
254
|
|
|
255
255
|
- **v0**
|
|
256
256
|
|
|
@@ -52,6 +52,7 @@ const get = {
|
|
|
52
52
|
account,
|
|
53
53
|
region,
|
|
54
54
|
tag,
|
|
55
|
+
team,
|
|
55
56
|
title
|
|
56
57
|
} = argv; // will be set to true and exit 1 if any get result contains an error or args invalid
|
|
57
58
|
|
|
@@ -69,6 +70,7 @@ const get = {
|
|
|
69
70
|
baseUrl,
|
|
70
71
|
account,
|
|
71
72
|
region,
|
|
73
|
+
team,
|
|
72
74
|
useCache: cache
|
|
73
75
|
});
|
|
74
76
|
const defsManager = await new _DefinitionsManager.DefinitionsManager(client).init();
|
|
@@ -166,34 +168,28 @@ ${defsManager.getDefsTableForHelpMsg()}`);
|
|
|
166
168
|
name: 'args',
|
|
167
169
|
desc: 'Command arguments, run "axway central get" to see the examples',
|
|
168
170
|
multiple: true,
|
|
169
|
-
required: false
|
|
170
|
-
type: 'string'
|
|
171
|
+
required: false
|
|
171
172
|
}],
|
|
172
173
|
options: { ..._types.commonCmdArgsDescription,
|
|
173
174
|
'-o, --output [value]': {
|
|
174
|
-
desc: `Additional output formats. One of: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}
|
|
175
|
-
type: 'string'
|
|
175
|
+
desc: `Additional output formats. One of: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}`
|
|
176
176
|
},
|
|
177
|
-
'-s, --scope [name|kind/name]
|
|
178
|
-
desc:
|
|
179
|
-
type: 'string'
|
|
177
|
+
'-s, --scope [name|kind/name]': {
|
|
178
|
+
desc: 'Scope name or kind/name for scoped resources'
|
|
180
179
|
},
|
|
181
180
|
'-q, --query [RSQL query]': {
|
|
182
|
-
desc:
|
|
183
|
-
type: 'string'
|
|
181
|
+
desc: 'RSQL-formatted query to search for filters that match specific parameters'
|
|
184
182
|
},
|
|
185
183
|
'--title [title]': {
|
|
186
|
-
desc:
|
|
187
|
-
type: 'string'
|
|
184
|
+
desc: 'Title of resource(s) to fetch'
|
|
188
185
|
},
|
|
189
186
|
'--attribute [key=value]': {
|
|
190
|
-
desc:
|
|
191
|
-
type: 'string'
|
|
187
|
+
desc: 'Attribute in key=value pair format to filter by'
|
|
192
188
|
},
|
|
193
189
|
'--tag [tag]': {
|
|
194
|
-
desc:
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
desc: 'Tag of resource(s) to fetch'
|
|
191
|
+
},
|
|
192
|
+
'--team [guid|name]': 'The team name or guid to use'
|
|
197
193
|
}
|
|
198
194
|
};
|
|
199
195
|
exports.get = get;
|
|
@@ -174,10 +174,10 @@ const configFiles = {
|
|
|
174
174
|
};
|
|
175
175
|
exports.configFiles = configFiles;
|
|
176
176
|
const agentsDocsUrl = {
|
|
177
|
-
V7: 'https://docs.axway.com/bundle/
|
|
178
|
-
AWS: 'https://docs.axway.com/bundle/
|
|
179
|
-
AZURE: 'https://docs.axway.com/bundle/
|
|
180
|
-
ISTIO: 'https://docs.axway.com/bundle/
|
|
177
|
+
V7: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/index.html',
|
|
178
|
+
AWS: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_aws_gateway/index.html',
|
|
179
|
+
AZURE: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_azure_gateway/index.html',
|
|
180
|
+
ISTIO: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/mesh_management/index.html'
|
|
181
181
|
}; // export * from './updaters';
|
|
182
182
|
|
|
183
183
|
exports.agentsDocsUrl = agentsDocsUrl;
|
|
@@ -411,7 +411,7 @@ const askToEnableTransactionLogging = async () => {
|
|
|
411
411
|
console.log(_chalk.default.gray(transactionLoggingMessages.samplingPercentageInfoMsg));
|
|
412
412
|
const samplingPercentage = await (0, _basicPrompts.askInput)({
|
|
413
413
|
msg: transactionLoggingMessages.enterSamplingPercentage,
|
|
414
|
-
defaultValue:
|
|
414
|
+
defaultValue: 10,
|
|
415
415
|
validate: (0, _basicPrompts.runValidations)((0, _basicPrompts.validateRegex)(_regex.percentageRegex, _regex.invalidPercentage))
|
|
416
416
|
});
|
|
417
417
|
let shouldReportAllErrors = _types.YesNo.Yes;
|
|
@@ -178,9 +178,9 @@ fullnameOverride: ""
|
|
|
178
178
|
# Health Check port
|
|
179
179
|
statusPort: 8990
|
|
180
180
|
|
|
181
|
-
#
|
|
182
|
-
# https://docs.axway.com/bundle/
|
|
183
|
-
#
|
|
181
|
+
# The following links document the environment variables for traceability.
|
|
182
|
+
# https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/agent-variables/index.html#common-variables-to-both-agents
|
|
183
|
+
# https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/agent-variables/index.html#specific-variables-for-traceability-agent
|
|
184
184
|
env:
|
|
185
185
|
APIGATEWAY_HEALTHCHECKPORT: 8090
|
|
186
186
|
APIGATEWAY_HEALTHCHECKPROTOCOL: "https"
|
|
@@ -304,9 +304,9 @@ fullnameOverride: ""
|
|
|
304
304
|
# Health Check port
|
|
305
305
|
statusPort: 8989
|
|
306
306
|
|
|
307
|
-
#
|
|
308
|
-
# https://docs.axway.com/bundle/
|
|
309
|
-
#
|
|
307
|
+
# The following links document the environment variables for discovery.
|
|
308
|
+
# https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/agent-variables/index.html#common-variables-to-both-agents
|
|
309
|
+
# https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/agent-variables/index.html#specific-variables-for-discovery-agent
|
|
310
310
|
env:
|
|
311
311
|
APIMANAGER_HOST: {{apiManagerHost}}
|
|
312
312
|
APIMANAGER_PORT: {{apiManagerPort}}
|
|
@@ -100,7 +100,7 @@ const gatewayConnectivity = async (installConfig, apiServerClient, defsManager)
|
|
|
100
100
|
The Amplify Istio Traceability Agent needs to be deployed to your Kubernetes cluster to collect transaction telemetry to send to the Amplify Central Observer and Visibility Dashboard.`));
|
|
101
101
|
console.log(`
|
|
102
102
|
For more details on client prerequesites or Kubernetes preparation refer to the documentation here:
|
|
103
|
-
https://docs.axway.com/bundle/
|
|
103
|
+
https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/mesh_management/build_hybrid_env/index.html
|
|
104
104
|
`);
|
|
105
105
|
const {
|
|
106
106
|
error
|
|
@@ -31,14 +31,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
31
|
// Complex prompts
|
|
32
32
|
//
|
|
33
33
|
const askTeamName = async client => {
|
|
34
|
-
var
|
|
34
|
+
var _teams$find;
|
|
35
|
+
|
|
36
|
+
const teams = await client.getTeams();
|
|
37
|
+
|
|
38
|
+
if (!(teams !== null && teams !== void 0 && teams.length)) {
|
|
39
|
+
throw new Error('Account has no teams!');
|
|
40
|
+
}
|
|
35
41
|
|
|
36
|
-
const res = await client.getTeams();
|
|
37
|
-
if (!res.data) throw Error('Get teams error.');
|
|
38
42
|
return (0, _basicPrompts.askList)({
|
|
39
43
|
msg: helpers.envMessages.selectTeam,
|
|
40
|
-
choices:
|
|
41
|
-
default: (
|
|
44
|
+
choices: teams.map(t => t.name).sort((name1, name2) => name1.localeCompare(name2)),
|
|
45
|
+
default: (_teams$find = teams.find(t => t.default)) === null || _teams$find === void 0 ? void 0 : _teams$find.name
|
|
42
46
|
});
|
|
43
47
|
};
|
|
44
48
|
|
|
@@ -48,7 +48,8 @@ class ApiServerClient {
|
|
|
48
48
|
baseUrl,
|
|
49
49
|
region,
|
|
50
50
|
account,
|
|
51
|
-
useCache
|
|
51
|
+
useCache,
|
|
52
|
+
team
|
|
52
53
|
} = {}) {
|
|
53
54
|
_defineProperty(this, "baseUrl", void 0);
|
|
54
55
|
|
|
@@ -58,11 +59,15 @@ class ApiServerClient {
|
|
|
58
59
|
|
|
59
60
|
_defineProperty(this, "account", void 0);
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
_defineProperty(this, "team", void 0);
|
|
63
|
+
|
|
64
|
+
log(`initializing client with params: baseUrl = ${baseUrl}, region = ${region}, account = ${account}, useCache = ${useCache}, team = ${team}`);
|
|
62
65
|
this.baseUrl = baseUrl;
|
|
63
66
|
this.account = account;
|
|
64
67
|
this.region = region;
|
|
65
68
|
this.useCache = useCache === undefined ? true : useCache; // using cache by default
|
|
69
|
+
|
|
70
|
+
this.team = team;
|
|
66
71
|
}
|
|
67
72
|
/**
|
|
68
73
|
* Build resource url based on its ResourceDefinition and passed scope def and name.
|
|
@@ -111,7 +116,8 @@ class ApiServerClient {
|
|
|
111
116
|
const service = await (0, _dataService.dataService)({
|
|
112
117
|
baseUrl: this.baseUrl,
|
|
113
118
|
region: this.region,
|
|
114
|
-
account: this.account
|
|
119
|
+
account: this.account,
|
|
120
|
+
team: this.team
|
|
115
121
|
});
|
|
116
122
|
const baseUrl = this.buildResourceBaseUrl({
|
|
117
123
|
resourceDef,
|
|
@@ -238,7 +244,8 @@ class ApiServerClient {
|
|
|
238
244
|
const service = await (0, _dataService.dataService)({
|
|
239
245
|
baseUrl: this.baseUrl,
|
|
240
246
|
region: this.region,
|
|
241
|
-
account: this.account
|
|
247
|
+
account: this.account,
|
|
248
|
+
team: this.team
|
|
242
249
|
});
|
|
243
250
|
const url = this.buildResourceBaseUrl({
|
|
244
251
|
resourceDef,
|
|
@@ -311,7 +318,8 @@ class ApiServerClient {
|
|
|
311
318
|
const service = await (0, _dataService.dataService)({
|
|
312
319
|
baseUrl: this.baseUrl,
|
|
313
320
|
region: this.region,
|
|
314
|
-
account: this.account
|
|
321
|
+
account: this.account,
|
|
322
|
+
team: this.team
|
|
315
323
|
});
|
|
316
324
|
const url = this.buildResourceBaseUrl({
|
|
317
325
|
resourceDef,
|
|
@@ -384,7 +392,8 @@ class ApiServerClient {
|
|
|
384
392
|
const service = await (0, _dataService.dataService)({
|
|
385
393
|
baseUrl: this.baseUrl,
|
|
386
394
|
region: this.region,
|
|
387
|
-
account: this.account
|
|
395
|
+
account: this.account,
|
|
396
|
+
team: this.team
|
|
388
397
|
});
|
|
389
398
|
const url = this.buildResourceBaseUrl({
|
|
390
399
|
resourceDef,
|
|
@@ -463,7 +472,8 @@ class ApiServerClient {
|
|
|
463
472
|
const service = await (0, _dataService.dataService)({
|
|
464
473
|
baseUrl: this.baseUrl,
|
|
465
474
|
region: this.region,
|
|
466
|
-
account: this.account
|
|
475
|
+
account: this.account,
|
|
476
|
+
team: this.team
|
|
467
477
|
});
|
|
468
478
|
const url = this.buildResourceBaseUrl({
|
|
469
479
|
resourceDef,
|
|
@@ -513,7 +523,8 @@ class ApiServerClient {
|
|
|
513
523
|
const service = await (0, _dataService.dataService)({
|
|
514
524
|
baseUrl: this.baseUrl,
|
|
515
525
|
region: this.region,
|
|
516
|
-
account: this.account
|
|
526
|
+
account: this.account,
|
|
527
|
+
team: this.team
|
|
517
528
|
});
|
|
518
529
|
const url = this.buildResourceBaseUrl({
|
|
519
530
|
resourceDef,
|
|
@@ -7,12 +7,8 @@ exports.CoreConfigController = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _amplifyCliUtils = require("@axway/amplify-cli-utils");
|
|
9
9
|
|
|
10
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
-
|
|
12
10
|
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
13
11
|
|
|
14
|
-
var _basicPrompts = require("./basicPrompts");
|
|
15
|
-
|
|
16
12
|
var _CliConfigManager = require("./CliConfigManager");
|
|
17
13
|
|
|
18
14
|
var _types = require("./types");
|
|
@@ -23,39 +19,48 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
23
19
|
|
|
24
20
|
const {
|
|
25
21
|
log
|
|
26
|
-
} = (0, _snooplogg.default)('central: CoreConfigController');
|
|
22
|
+
} = (0, _snooplogg.default)('central: CoreConfigController'); // TODO: https://jira.axway.com/browse/APIGOV-20520
|
|
23
|
+
// interface AuthenticationError extends Error {
|
|
24
|
+
// errors?: Array<object>;
|
|
25
|
+
// }
|
|
27
26
|
|
|
28
27
|
class CoreConfigController {
|
|
29
28
|
/**
|
|
30
29
|
* Get authentication info
|
|
31
|
-
* @param clientId client id to use
|
|
30
|
+
* @param {String} clientId client id to use
|
|
31
|
+
* @param {String} [team] The team name or guid to use, otherwise fallsback to the default from
|
|
32
|
+
* the Axway CLI config.
|
|
32
33
|
* @returns object containing token and orgId. For service accounts orgId is undefined.
|
|
33
34
|
* @throws 401 if no authenticated account found.
|
|
34
35
|
*/
|
|
35
36
|
async getAuthInfo({
|
|
36
37
|
account,
|
|
37
|
-
clientId
|
|
38
|
+
clientId,
|
|
39
|
+
team
|
|
38
40
|
} = {}) {
|
|
39
|
-
var
|
|
41
|
+
var _devOpsAccount$org;
|
|
40
42
|
|
|
41
|
-
const configCtrl = new _CliConfigManager.CliConfigManager();
|
|
43
|
+
const configCtrl = new _CliConfigManager.CliConfigManager();
|
|
44
|
+
const config = (0, _amplifyCliUtils.loadConfig)(); // note: remove this validator after couple of versions
|
|
42
45
|
|
|
43
46
|
configCtrl.validateSavedConfigKeys();
|
|
44
|
-
log(`getAuthInfo, received clientId = ${clientId}, account = ${account}`);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
log(`getAuthInfo, received clientId = ${clientId}, account = ${account}, team = ${team}`);
|
|
48
|
+
const baseUrl = configCtrl.get(_CliConfigManager.CliConfigKeys.BASE_URL); // environment defined by using central cli "base-url" or axway "env" configs if set,
|
|
49
|
+
// otherwise its undefined (equals to prod)
|
|
50
|
+
|
|
51
|
+
const environment = !baseUrl || baseUrl === _types.ProdBaseUrls.US || baseUrl === _types.ProdBaseUrls.EU ? config.get('env') : 'preprod';
|
|
52
|
+
log(`getAuthInfo, baseUrl = ${baseUrl}, environment = ${environment}`);
|
|
53
|
+
const {
|
|
54
|
+
sdk
|
|
55
|
+
} = (0, _amplifyCliUtils.initSDK)({
|
|
56
|
+
env: environment
|
|
57
|
+
}, config);
|
|
58
|
+
let {
|
|
59
|
+
devOpsAccount
|
|
60
|
+
} = CoreConfigController;
|
|
61
|
+
|
|
62
|
+
if (!devOpsAccount || account && devOpsAccount.name !== account) {
|
|
47
63
|
log(`getAuthInfo, no cached devOpsAccount found, or account name does not match`);
|
|
48
|
-
const baseUrl = configCtrl.get(_CliConfigManager.CliConfigKeys.BASE_URL); // environment defined by using central cli "base-url" or axway "env" configs if set,
|
|
49
|
-
// otherwise its undefined (equals to prod)
|
|
50
|
-
|
|
51
|
-
const environment = !baseUrl || baseUrl === _types.ProdBaseUrls.US || baseUrl === _types.ProdBaseUrls.EU ? this.getConfig('env') : 'preprod';
|
|
52
|
-
log(`getAuthInfo, baseUrl = ${baseUrl}, environment = ${environment}`);
|
|
53
|
-
const {
|
|
54
|
-
config,
|
|
55
|
-
sdk
|
|
56
|
-
} = (0, _amplifyCliUtils.initSDK)({
|
|
57
|
-
env: environment
|
|
58
|
-
});
|
|
59
64
|
|
|
60
65
|
if (clientId) {
|
|
61
66
|
// TODO: client-id is a legacy option used only by proxies promote/create, should be removed
|
|
@@ -65,11 +70,14 @@ class CoreConfigController {
|
|
|
65
70
|
validate: true
|
|
66
71
|
});
|
|
67
72
|
const matchingAccount = list.find(a => a.auth.clientId === clientId);
|
|
68
|
-
|
|
73
|
+
|
|
74
|
+
if (matchingAccount) {
|
|
75
|
+
devOpsAccount = await sdk.auth.find(matchingAccount.name);
|
|
76
|
+
}
|
|
69
77
|
} else if (account) {
|
|
70
78
|
// ELSE IF: account name passed - ignoring defaultAccount and other accounts
|
|
71
79
|
log(`getAuthInfo, account value passed, trying to find a matching account`);
|
|
72
|
-
|
|
80
|
+
devOpsAccount = await sdk.auth.find(account);
|
|
73
81
|
} else {
|
|
74
82
|
// ELSE: trying to get any authenticated account
|
|
75
83
|
log(`getAuthInfo, account value not passed, trying to find default/any match`);
|
|
@@ -80,28 +88,14 @@ class CoreConfigController {
|
|
|
80
88
|
|
|
81
89
|
if (list.length === 1) {
|
|
82
90
|
log(`getAuthInfo, using a single account found with name: ${list[0].name}`);
|
|
83
|
-
|
|
91
|
+
devOpsAccount = list[0];
|
|
84
92
|
} else if (list.length > 1) {
|
|
85
93
|
// try to find the default account
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (defaultAccount) {
|
|
89
|
-
log(`getAuthInfo, match found for defaultAccount, refreshing its token`);
|
|
90
|
-
CoreConfigController.devOpsAccount = await sdk.auth.find(defaultAccount.name);
|
|
91
|
-
} else {
|
|
92
|
-
log(`getAuthInfo, no match found for defaultAccount`);
|
|
93
|
-
const selectedName = await (0, _basicPrompts.askList)({
|
|
94
|
-
msg: 'Multiple authenticated accounts found, please select which one you want to use',
|
|
95
|
-
choices: Array.from(new Set(list.map(a => a.name)))
|
|
96
|
-
});
|
|
97
|
-
console.log((0, _chalk.default)`{grey If you always want to use this account by default, run:\naxway config set auth.defaultAccount ${selectedName}}\n`);
|
|
98
|
-
log(`getAuthInfo, refreshing token for selected account: ${selectedName}`);
|
|
99
|
-
CoreConfigController.devOpsAccount = await sdk.auth.find(selectedName);
|
|
100
|
-
}
|
|
94
|
+
devOpsAccount = list.find(a => a.name === config.get('auth.defaultAccount')) || list.find(a => a.default) || list[0];
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
|
|
104
|
-
if (!
|
|
98
|
+
if (!devOpsAccount) {
|
|
105
99
|
// TODO: piece of old logic here, move throwing out of the method?
|
|
106
100
|
// temporary commenting out the new functionality and reverting back to the old one, will be fixed with:
|
|
107
101
|
// https://jira.axway.com/browse/APIGOV-20520
|
|
@@ -119,43 +113,48 @@ class CoreConfigController {
|
|
|
119
113
|
}]
|
|
120
114
|
};
|
|
121
115
|
}
|
|
116
|
+
|
|
117
|
+
CoreConfigController.devOpsAccount = devOpsAccount;
|
|
122
118
|
}
|
|
123
119
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
log(`getAuthInfo, returning orgId = ${orgId}`);
|
|
130
|
-
log(`getAuthInfo, returning orgRegion = ${orgRegion}`);
|
|
131
|
-
return {
|
|
132
|
-
orgId,
|
|
133
|
-
orgRegion,
|
|
134
|
-
token
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Get all or specific config value from core cli.
|
|
139
|
-
* @returns entire object config or a specific value if key passed.
|
|
140
|
-
*/
|
|
120
|
+
const result = {
|
|
121
|
+
orgId: devOpsAccount.isPlatform ? `${devOpsAccount.org.id}` : undefined,
|
|
122
|
+
orgRegion: (_devOpsAccount$org = devOpsAccount.org) === null || _devOpsAccount$org === void 0 ? void 0 : _devOpsAccount$org.region,
|
|
123
|
+
token: devOpsAccount.auth.tokens.access_token
|
|
124
|
+
}; // now that we have resolved the account, we can validate the team
|
|
141
125
|
|
|
126
|
+
if (team) {
|
|
127
|
+
var _devOpsAccount$org$te;
|
|
128
|
+
|
|
129
|
+
const teamObj = (_devOpsAccount$org$te = devOpsAccount.org.teams) === null || _devOpsAccount$org$te === void 0 ? void 0 : _devOpsAccount$org$te.find(t => {
|
|
130
|
+
return t.guid.toLowerCase() === team.toLowerCase() || t.name.toLowerCase() === team.toLowerCase();
|
|
131
|
+
});
|
|
142
132
|
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
if (!teamObj) {
|
|
134
|
+
throw new Error(`Unable to find team "${team}" in the "${devOpsAccount.org.name}" organization`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
result.teamGuid = teamObj.guid;
|
|
138
|
+
}
|
|
145
139
|
|
|
146
|
-
|
|
140
|
+
log(`getAuthInfo, returning account = ${devOpsAccount.name}`);
|
|
141
|
+
log(`getAuthInfo, returning token = ${result.token.substring(0, 5)}*****${result.token.substring(result.token.length - 5)}`);
|
|
142
|
+
log(`getAuthInfo, returning orgId = ${result.orgId}`);
|
|
143
|
+
log(`getAuthInfo, returning orgRegion = ${result.orgRegion}`);
|
|
144
|
+
log(`getAuthInfo, returning teamGuid = ${result.teamGuid}`);
|
|
145
|
+
return result;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
static getEnv() {
|
|
150
|
-
var
|
|
149
|
+
var _CoreConfigController, _CoreConfigController2;
|
|
151
150
|
|
|
152
|
-
return ((
|
|
151
|
+
return ((_CoreConfigController = CoreConfigController.devOpsAccount) === null || _CoreConfigController === void 0 ? void 0 : (_CoreConfigController2 = _CoreConfigController.auth) === null || _CoreConfigController2 === void 0 ? void 0 : _CoreConfigController2.env) || _types.Platforms.prod;
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
static getAuthUrl() {
|
|
156
|
-
var
|
|
155
|
+
var _CoreConfigController3, _CoreConfigController4;
|
|
157
156
|
|
|
158
|
-
return ((
|
|
157
|
+
return ((_CoreConfigController3 = CoreConfigController.devOpsAccount) === null || _CoreConfigController3 === void 0 ? void 0 : (_CoreConfigController4 = _CoreConfigController3.auth) === null || _CoreConfigController4 === void 0 ? void 0 : _CoreConfigController4.baseUrl) || _types.AuthUrls.Prod;
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
}
|
|
@@ -9,10 +9,6 @@ var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
|
9
9
|
|
|
10
10
|
var _amplifyCliUtils = require("@axway/amplify-cli-utils");
|
|
11
11
|
|
|
12
|
-
var _dataService = require("./dataService");
|
|
13
|
-
|
|
14
|
-
var _types = require("./types");
|
|
15
|
-
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
13
|
|
|
18
14
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
@@ -127,13 +123,19 @@ class PlatformClient {
|
|
|
127
123
|
|
|
128
124
|
if (_classPrivateFieldGet(this, _accountName)) {
|
|
129
125
|
accountInfo = await _classPrivateFieldGet(this, _amplifySdk).auth.find(_classPrivateFieldGet(this, _accountName), defaultTeams);
|
|
130
|
-
|
|
126
|
+
|
|
127
|
+
if (!accountInfo) {
|
|
128
|
+
throw new Error(`Account "${_classPrivateFieldGet(this, _accountName)}" not found`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!accountInfo) {
|
|
131
133
|
const accountArray = await _classPrivateFieldGet(this, _amplifySdk).auth.list({
|
|
132
134
|
defaultTeams,
|
|
133
135
|
validate: true
|
|
134
136
|
});
|
|
135
137
|
|
|
136
|
-
if (accountArray
|
|
138
|
+
if (accountArray) {
|
|
137
139
|
accountInfo = accountArray.find(nextAccount => nextAccount.default) || accountArray[0];
|
|
138
140
|
}
|
|
139
141
|
} // Make sure "subscriptions" is defined since Amplify SDK requires it. (Will throw error if missing.)
|
|
@@ -159,28 +161,17 @@ class PlatformClient {
|
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
async getTeams() {
|
|
162
|
-
|
|
163
|
-
const result = {
|
|
164
|
-
data: null,
|
|
165
|
-
error: null
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
try {
|
|
169
|
-
const service = await (0, _dataService.dataService)({
|
|
170
|
-
baseUrl: _classPrivateFieldGet(this, _baseUrl),
|
|
171
|
-
basePath: _types.BasePaths.Platform,
|
|
172
|
-
account: _classPrivateFieldGet(this, _accountName)
|
|
173
|
-
}); // Not using "getWithPagination" method here because /teams API does not support pagination
|
|
174
|
-
|
|
175
|
-
const response = await service.get('/team');
|
|
176
|
-
result.data = response;
|
|
177
|
-
} catch (e) {
|
|
178
|
-
if (e.errors && Array.isArray(e.errors)) {
|
|
179
|
-
result.error = e.errors;
|
|
180
|
-
} else throw e;
|
|
181
|
-
}
|
|
164
|
+
var _account$team, _teams$find;
|
|
182
165
|
|
|
183
|
-
|
|
166
|
+
log(`getTeams`);
|
|
167
|
+
const account = await this.getAccountInfo();
|
|
168
|
+
const {
|
|
169
|
+
teams
|
|
170
|
+
} = await _classPrivateFieldGet(this, _amplifySdk).team.list(account);
|
|
171
|
+
const teamGuid = ((_account$team = account.team) === null || _account$team === void 0 ? void 0 : _account$team.guid) && ((_teams$find = teams.find(team => team.guid === account.team.guid)) === null || _teams$find === void 0 ? void 0 : _teams$find.guid);
|
|
172
|
+
return teams.map(team => ({ ...team,
|
|
173
|
+
default: teamGuid && team.guid === teamGuid || !teamGuid && team.default
|
|
174
|
+
}));
|
|
184
175
|
}
|
|
185
176
|
|
|
186
177
|
}
|
|
@@ -113,23 +113,34 @@ const updateRequestError = err => {
|
|
|
113
113
|
Object.assign(err, jsonBody);
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* Creates an object with various functions communicating with the API Server.
|
|
118
|
+
* @param {String} clientId Client id to use.
|
|
119
|
+
* @param {String} [team] The preferred team to use. This value overrides the default from the Axway CLI config.
|
|
120
|
+
* @param {String} [region] The preferred region to use.
|
|
121
|
+
* @returns Object containing data retrieval functions.
|
|
122
|
+
*/
|
|
123
|
+
|
|
116
124
|
|
|
117
125
|
const dataService = async ({
|
|
118
126
|
account,
|
|
119
127
|
baseUrl,
|
|
120
128
|
basePath = _types.BasePaths.ApiServer,
|
|
121
129
|
clientId,
|
|
122
|
-
region
|
|
130
|
+
region,
|
|
131
|
+
team
|
|
123
132
|
}) => {
|
|
124
133
|
// see above
|
|
125
134
|
// await versionCheckWarning();
|
|
126
135
|
const {
|
|
127
136
|
orgId,
|
|
128
137
|
orgRegion,
|
|
138
|
+
teamGuid,
|
|
129
139
|
token
|
|
130
140
|
} = await new _CoreConfigController.CoreConfigController().getAuthInfo({
|
|
131
141
|
account,
|
|
132
|
-
clientId
|
|
142
|
+
clientId,
|
|
143
|
+
team
|
|
133
144
|
});
|
|
134
145
|
const url = await getBaseUrl(baseUrl, basePath, region, orgRegion);
|
|
135
146
|
const defaultHeaders = getDefaultHeaders({
|
|
@@ -140,6 +151,13 @@ const dataService = async ({
|
|
|
140
151
|
|
|
141
152
|
const fetch = async (method, url, params = {}) => {
|
|
142
153
|
try {
|
|
154
|
+
// add the team guid
|
|
155
|
+
if (teamGuid) {
|
|
156
|
+
const parsed = new _url.URL(url);
|
|
157
|
+
parsed.searchParams.set('query', `owner.id==${teamGuid}`);
|
|
158
|
+
url = parsed.toString();
|
|
159
|
+
}
|
|
160
|
+
|
|
143
161
|
const response = await got[method](url, {
|
|
144
162
|
followRedirect: false,
|
|
145
163
|
retry: 0,
|
package/dist/common/types.js
CHANGED
|
@@ -11,7 +11,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
11
11
|
|
|
12
12
|
const cliVersionHeader = 'x-axway-cli-version';
|
|
13
13
|
exports.cliVersionHeader = cliVersionHeader;
|
|
14
|
-
const docsUrl = 'https://docs.axway.com/bundle/
|
|
14
|
+
const docsUrl = 'https://docs.axway.com/bundle/amplify-central/page/docs/index.html';
|
|
15
15
|
exports.docsUrl = docsUrl;
|
|
16
16
|
const ABORT_TIMEOUT = process.env.NODE_ENV === 'test' ? 1e3 : 30e3;
|
|
17
17
|
exports.ABORT_TIMEOUT = ABORT_TIMEOUT;
|
|
@@ -149,9 +149,9 @@ const APICDeployments = {
|
|
|
149
149
|
};
|
|
150
150
|
exports.APICDeployments = APICDeployments;
|
|
151
151
|
const commonCmdArgsDescription = {
|
|
152
|
-
'--account [value]':
|
|
153
|
-
'--region [value]':
|
|
154
|
-
'--no-cache':
|
|
152
|
+
'--account [value]': 'Override your default account config',
|
|
153
|
+
'--region [value]': 'Override your region config',
|
|
154
|
+
'--no-cache': 'Do not use cache when communicating with the server',
|
|
155
155
|
'--base-url [value]': {
|
|
156
156
|
hidden: true
|
|
157
157
|
},
|
|
@@ -726,5 +726,7 @@ class IstioInstallValues {
|
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
}
|
|
729
|
+
/** Provides information for a platform team. */
|
|
730
|
+
|
|
729
731
|
|
|
730
732
|
exports.IstioInstallValues = IstioInstallValues;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axway/axway-central-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Manage APIs, services and publish to the Unified Catalog",
|
|
5
5
|
"homepage": "https://platform.axway.com",
|
|
6
6
|
"author": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@axway/amplify-cli-utils": "^5.0.3",
|
|
45
45
|
"chalk": "^4.1.2",
|
|
46
|
-
"cli-kit": "^1.
|
|
46
|
+
"cli-kit": "^1.15.0",
|
|
47
47
|
"dayjs": "^1.10.7",
|
|
48
48
|
"easy-table": "^1.2.0",
|
|
49
49
|
"extract-zip": "^2.0.1",
|
|
@@ -60,42 +60,42 @@
|
|
|
60
60
|
"tmp": "^0.2.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@babel/cli": "^7.
|
|
64
|
-
"@babel/core": "^7.
|
|
65
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
66
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
67
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
68
|
-
"@babel/preset-env": "^7.
|
|
69
|
-
"@babel/preset-typescript": "^7.
|
|
63
|
+
"@babel/cli": "^7.16.0",
|
|
64
|
+
"@babel/core": "^7.16.0",
|
|
65
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
66
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
67
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
68
|
+
"@babel/preset-env": "^7.16.4",
|
|
69
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
70
70
|
"@types/chai": "^4.2.22",
|
|
71
71
|
"@types/chai-as-promised": "^7.1.4",
|
|
72
72
|
"@types/easy-table": "^0.0.33",
|
|
73
73
|
"@types/form-data": "^2.5.0",
|
|
74
74
|
"@types/fs-extra": "^9.0.13",
|
|
75
75
|
"@types/inquirer": "^8.1.3",
|
|
76
|
-
"@types/js-yaml": "^4.0.
|
|
77
|
-
"@types/lodash": "^4.14.
|
|
76
|
+
"@types/js-yaml": "^4.0.5",
|
|
77
|
+
"@types/lodash": "^4.14.177",
|
|
78
78
|
"@types/mocha": "^9.0.0",
|
|
79
|
-
"@types/node": "^16.11.
|
|
79
|
+
"@types/node": "^16.11.10",
|
|
80
80
|
"@types/rx": "^4.1.2",
|
|
81
81
|
"@types/semver": "^7.3.9",
|
|
82
|
-
"@types/sinon": "^10.0.
|
|
82
|
+
"@types/sinon": "^10.0.6",
|
|
83
83
|
"@types/tmp": "^0.2.2",
|
|
84
84
|
"@types/update-notifier": "^5.1.0",
|
|
85
|
-
"@types/uuid": "^8.3.
|
|
85
|
+
"@types/uuid": "^8.3.3",
|
|
86
86
|
"babel-plugin-lodash": "^3.3.4",
|
|
87
87
|
"chai": "^4.3.4",
|
|
88
88
|
"chai-as-promised": "^7.1.1",
|
|
89
|
-
"core-js": "^3.19.
|
|
89
|
+
"core-js": "^3.19.1",
|
|
90
90
|
"mocha": "^9.1.3",
|
|
91
|
-
"nock": "^13.1
|
|
92
|
-
"nodemon": "^2.0.
|
|
91
|
+
"nock": "^13.2.1",
|
|
92
|
+
"nodemon": "^2.0.15",
|
|
93
93
|
"nyc": "^15.1.0",
|
|
94
94
|
"prettier": "^2.4.1",
|
|
95
95
|
"sinon": "^11.1.2",
|
|
96
|
-
"source-map-support": "^0.5.
|
|
96
|
+
"source-map-support": "^0.5.21",
|
|
97
97
|
"ts-mocha": "^8.0.0",
|
|
98
|
-
"typescript": "^4.
|
|
98
|
+
"typescript": "^4.5.2"
|
|
99
99
|
},
|
|
100
100
|
"jest": {
|
|
101
101
|
"verbose": true,
|