@axway/axway-central-cli 4.5.0 → 4.6.0-rc.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.
Files changed (83) hide show
  1. package/.security-profile-branches.json +18 -0
  2. package/package.json +1 -1
  3. package/dist/cli.js +0 -71
  4. package/dist/commands/apply/index.js +0 -112
  5. package/dist/commands/completion/index.js +0 -100
  6. package/dist/commands/config/common/index.js +0 -28
  7. package/dist/commands/config/index.js +0 -20
  8. package/dist/commands/config/list.js +0 -24
  9. package/dist/commands/config/set.js +0 -102
  10. package/dist/commands/config/unset.js +0 -48
  11. package/dist/commands/create/agentResource.js +0 -108
  12. package/dist/commands/create/environment.js +0 -62
  13. package/dist/commands/create/index.js +0 -109
  14. package/dist/commands/create/serviceAccount.js +0 -15
  15. package/dist/commands/delete/index.js +0 -196
  16. package/dist/commands/edit/environment.js +0 -101
  17. package/dist/commands/edit/index.js +0 -28
  18. package/dist/commands/get/index.js +0 -272
  19. package/dist/commands/install/agents.js +0 -290
  20. package/dist/commands/install/apigeexAgents.js +0 -223
  21. package/dist/commands/install/apigeexSaasAgents.js +0 -300
  22. package/dist/commands/install/awsAgents.js +0 -525
  23. package/dist/commands/install/awsSaasAgents.js +0 -508
  24. package/dist/commands/install/azureAgents.js +0 -242
  25. package/dist/commands/install/azureSaasAgents.js +0 -519
  26. package/dist/commands/install/backstageAgents.js +0 -167
  27. package/dist/commands/install/edgeAgents.js +0 -409
  28. package/dist/commands/install/gitHubSaasAgents.js +0 -294
  29. package/dist/commands/install/gitLabAgents.js +0 -178
  30. package/dist/commands/install/graylogAgent.js +0 -147
  31. package/dist/commands/install/helpers/creators.js +0 -359
  32. package/dist/commands/install/helpers/deleters.js +0 -36
  33. package/dist/commands/install/helpers/getters.js +0 -95
  34. package/dist/commands/install/helpers/index.js +0 -267
  35. package/dist/commands/install/helpers/inputs.js +0 -593
  36. package/dist/commands/install/helpers/regex.js +0 -67
  37. package/dist/commands/install/helpers/templates/apigeexTemplates.js +0 -109
  38. package/dist/commands/install/helpers/templates/awsTemplates.js +0 -129
  39. package/dist/commands/install/helpers/templates/azureTemplates.js +0 -125
  40. package/dist/commands/install/helpers/templates/backstageTemplates.js +0 -95
  41. package/dist/commands/install/helpers/templates/edgeTemplates.js +0 -360
  42. package/dist/commands/install/helpers/templates/gitLabTemplates.js +0 -66
  43. package/dist/commands/install/helpers/templates/graylogTemplates.js +0 -75
  44. package/dist/commands/install/helpers/templates/ibmAPIConnectTemplates.js +0 -116
  45. package/dist/commands/install/helpers/templates/istioTemplates.js +0 -214
  46. package/dist/commands/install/helpers/templates/kafkaTemplates.js +0 -194
  47. package/dist/commands/install/helpers/templates/sapApiPortalTemplates.js +0 -114
  48. package/dist/commands/install/helpers/templates/softwareAGWebMethodsTemplates.js +0 -93
  49. package/dist/commands/install/helpers/templates/traceableTemplates.js +0 -135
  50. package/dist/commands/install/helpers/templates/wso2Templates.js +0 -85
  51. package/dist/commands/install/helpers/util.js +0 -26
  52. package/dist/commands/install/ibmAPIConnectAgents.js +0 -213
  53. package/dist/commands/install/index.js +0 -36
  54. package/dist/commands/install/istioAgents.js +0 -346
  55. package/dist/commands/install/kafkaAgents.js +0 -303
  56. package/dist/commands/install/platform.js +0 -175
  57. package/dist/commands/install/sapApiPortalAgents.js +0 -198
  58. package/dist/commands/install/softwareAGWebMethodsAgents.js +0 -161
  59. package/dist/commands/install/swaggerHubSaasAgents.js +0 -272
  60. package/dist/commands/install/traceableAgents.js +0 -257
  61. package/dist/commands/install/traceableSaasAgents.js +0 -275
  62. package/dist/commands/install/wso2Agents.js +0 -163
  63. package/dist/commands/productize/helpers/productizationHelper.js +0 -408
  64. package/dist/commands/productize/index.js +0 -99
  65. package/dist/common/ApiServerClient.js +0 -1109
  66. package/dist/common/CacheController.js +0 -146
  67. package/dist/common/CliConfigManager.js +0 -76
  68. package/dist/common/CompositeError.js +0 -95
  69. package/dist/common/CoreConfigController.js +0 -174
  70. package/dist/common/DefinitionsManager.js +0 -298
  71. package/dist/common/Kubectl.js +0 -68
  72. package/dist/common/PlatformClient.js +0 -128
  73. package/dist/common/Renderer.js +0 -409
  74. package/dist/common/TmpFile.js +0 -96
  75. package/dist/common/bashCommands.js +0 -97
  76. package/dist/common/basicPrompts.js +0 -160
  77. package/dist/common/dataService.js +0 -312
  78. package/dist/common/errorHandler.js +0 -46
  79. package/dist/common/modules.d.js +0 -1
  80. package/dist/common/resultsRenderers.js +0 -164
  81. package/dist/common/types.js +0 -746
  82. package/dist/common/utils.js +0 -476
  83. package/dist/main.js +0 -8
@@ -1,272 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.get = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
- var _ApiServerClient = require("../../common/ApiServerClient");
10
- var _DefinitionsManager = require("../../common/DefinitionsManager");
11
- var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
12
- var _resultsRenderers = require("../../common/resultsRenderers");
13
- var _types = require("../../common/types");
14
- var _utils = require("../../common/utils");
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- const {
17
- log
18
- } = (0, _snooplogg.default)('engage: get');
19
- const getListOrByName = async (resourceDef, client, scopeName, resourceName, scopeDef, query, progressListener, expand, langDef, fieldSet) => {
20
- return resourceName ? await client.getResourceByName({
21
- resourceDef,
22
- resourceName,
23
- scopeDef,
24
- scopeName,
25
- expand,
26
- langDef,
27
- fieldSet
28
- }) : await client.getResourcesList({
29
- resourceDef,
30
- scopeDef,
31
- scopeName,
32
- query,
33
- progressListener,
34
- expand,
35
- langDef,
36
- fieldSet
37
- });
38
- };
39
- const get = exports.get = {
40
- action: async function ({
41
- argv,
42
- console
43
- }) {
44
- if (!argv.team && argv.owner === false) {
45
- // no --team set and --no-owner was set, so we set the team to `null` which will know
46
- // to get teams that do not have an owner
47
- argv.team = null;
48
- }
49
- const {
50
- args,
51
- attribute,
52
- baseUrl,
53
- cache,
54
- account,
55
- region,
56
- tag,
57
- team,
58
- title
59
- } = argv;
60
- // will be set to true and exit 1 if any get result contains an error or args invalid
61
- let isCmdError = true;
62
- // name can be provided or not (args[0] is the resource type)
63
- const resourceName = args[1];
64
- // verify output argument
65
- if (!!argv.output && !(argv.output in _types.OutputTypes)) throw Error(`invalid "output" (-o,--output) value provided, allowed: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}`);
66
- const renderer = new _Renderer.default(console, argv.output);
67
- const getResults = [];
68
- try {
69
- // get specs and allowed words
70
- const client = new _ApiServerClient.ApiServerClient({
71
- baseUrl,
72
- account,
73
- region,
74
- team,
75
- useCache: cache
76
- });
77
- const defsManager = await new _DefinitionsManager.DefinitionsManager(client).init();
78
- const scope = (0, _utils.parseScopeParam)(argv.scope);
79
- let languageExpand = argv.language;
80
- const languageDefinition = argv.languageDefinition;
81
- const formattedFilter = (0, _utils.transformSimpleFilters)(title, attribute, tag);
82
- const query = argv.query ? argv.query : formattedFilter;
83
- // verify either "--language" or "--languageDefinition" argument is passed and error when both are passed
84
- if (languageExpand && languageDefinition) {
85
- throw Error('You must specify either of the "--language" or "--languageDefinition" argument and not both.');
86
- }
87
- if (languageDefinition && !argv.output) {
88
- throw Error('The "--languageDefinition" argument can only be used with output(-o,--output) argument');
89
- }
90
- if (languageExpand) {
91
- // when "*" is provided, expand all supported languages
92
- let lang = "";
93
- let i = 0;
94
- if (languageExpand.trim() === "*") {
95
- lang = "languages-*";
96
- } else {
97
- let langCodeArr = languageExpand.split(',');
98
- langCodeArr.forEach(v => {
99
- if (i < langCodeArr.length - 1) {
100
- lang = lang + "languages-" + v.trim() + ",";
101
- } else {
102
- lang = lang + "languages-" + v.trim();
103
- }
104
- i++;
105
- });
106
- }
107
- languageExpand = 'languages,' + lang;
108
- }
109
- if (argv.query && formattedFilter) {
110
- console.log(`${_chalk.default.yellow('Both simple queries and advanced query parameters have been provided. Only the advanced query parameter will be applied.')}`);
111
- }
112
- // verify passed args
113
- if (!args.length) {
114
- renderer.error('Error: You must specify the type of resource to get.');
115
- console.log(`\nUSAGE:
116
-
117
- Get a list of the resources:
118
- ${_chalk.default.cyan(`axway engage get <Resource>`)}\n
119
- Get a list of multiple resources:
120
- ${_chalk.default.cyan(`axway engage get <Resource1>,<Resource2>,...,<ResourceN>`)}\n
121
- Get a list of resources in a specific scope:
122
- ${_chalk.default.cyan(`axway engage get <Resource> -s/--scope <Scope Kind>/<Scope Name>`)}\n
123
- Get a list of resources matching a specific RSQL query:
124
- ${_chalk.default.cyan(`axway engage get <Resource> -q/--query "<RSQL query>"`)}\n
125
- Get a specific resource by name in all scopes with a specific name:
126
- ${_chalk.default.cyan(`axway engage get <Resource> <Name> -s/--scope <Scope Name>`)}\n
127
- Get a specific resource by name in a specific scope:
128
- ${_chalk.default.cyan(`axway engage get <Resource> <Name> -s/--scope <Scope Kind>/<Scope Name>`)}\n
129
-
130
- The server supports the following resources:
131
-
132
- ${defsManager.getDefsTableForHelpMsg()}`);
133
- process.exit(1);
134
- }
135
-
136
- // Start showing download progress.
137
- const downloadMessage = 'Retrieving resource(s)';
138
- renderer.startSpin(downloadMessage);
139
- const progressListener = percent => {
140
- renderer.updateSpinText(`${downloadMessage} - ${percent}%`);
141
- };
142
-
143
- // parse passed resources types (if passed comma-separated)
144
- for (const typedResource of args[0].split(',')) {
145
- const defs = defsManager.findDefsByWord(typedResource);
146
- // is typed resource known?
147
- if (!defs) throw Error(`the server doesn't have a resource type "${typedResource}"`);
148
- // check if a user is trying to get a scoped-only resource by name without providing a scope name
149
- if (defs.every(defs => !!defs.scope) && resourceName && !scope) throw Error(`scope name param (-s/--scope) is required for the scoped "${defs[0].resource.spec.kind}" resource.`);
150
- // verify passed scope param kind
151
- (0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope);
152
-
153
- /**
154
- 1) If "scope" param provided: execute getByName or getList calls for every definition that match this scope name/kind.
155
- 2) If "scope" param is not provided: execute list (get all) api calls for scoped resources without providing the scope in
156
- the path so api-server returns the entire list in all scopes. For example, using "Document" kind and calling
157
- https://apicentral.axway.com/apis/catalog/v1alpha1/documents returns a list of documents in Asset and AssetRelease
158
- scopes in a single api call. So getting unique list of groups and finding first matching definitions to do a call
159
- Note: this logic might have some edge cases if same kind can be used for "scoped" and "scope" resources and api-server is
160
- not handling this case correctly anymore.
161
- */
162
- if (scope) {
163
- const results = await Promise.all(defs.filter(defs => !scope.kind || !defs.scope || defs.scope.spec.kind === scope.kind).map(async defs => ({
164
- response: await getListOrByName(defs.resource, client, scope.name, resourceName, defs.scope, query, progressListener, languageExpand, languageDefinition, argv.output ? undefined : getFieldSetFromDefinitionColumns(defs)),
165
- cli: defs.cli
166
- })));
167
- results.forEach(({
168
- response,
169
- cli
170
- }) => {
171
- getResults.push({
172
- columns: cli.spec.columns,
173
- response
174
- });
175
- });
176
- } else {
177
- const defsMatchingGroup = {};
178
- defs.forEach(def => {
179
- if (!defsMatchingGroup[def.resource.metadata.scope.name]) {
180
- defsMatchingGroup[def.resource.metadata.scope.name] = def;
181
- }
182
- });
183
- const results = await Promise.all(Object.values(defsMatchingGroup).map(async defs => ({
184
- response: await getListOrByName(defs.resource, client, undefined, resourceName, undefined, query, progressListener, languageExpand, languageDefinition, argv.output ? undefined : getFieldSetFromDefinitionColumns(defs)),
185
- cli: defs.cli
186
- })));
187
- results.forEach(({
188
- response,
189
- cli
190
- }) => {
191
- getResults.push({
192
- columns: cli.spec.columns,
193
- response
194
- });
195
- });
196
- }
197
- }
198
-
199
- // resolve team guids
200
- for (const obj of getResults) {
201
- await (0, _resultsRenderers.resolveTeamNames)(obj);
202
- }
203
-
204
- // considering the command successful if at least 1 response found
205
- isCmdError = !getResults.filter(res => res.response.data !== null).length;
206
- renderer.renderGetResults(getResults, 'Resource(s) successfully retrieved', languageDefinition);
207
- } catch (e) {
208
- log('command error', e);
209
- isCmdError = true;
210
- renderer.anyError(e);
211
- } finally {
212
- log('command complete');
213
- renderer.stopSpin();
214
- if (isCmdError) process.exit(1);
215
- }
216
- },
217
- desc: 'List one or more resources',
218
- args: [{
219
- name: 'args',
220
- desc: 'Command arguments, run "axway engage get" to see the examples',
221
- multiple: true,
222
- required: false
223
- }],
224
- options: {
225
- ..._types.commonCmdArgsDescription,
226
- '-o, --output [value]': {
227
- desc: `Additional output formats. One of: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}`
228
- },
229
- '-s, --scope [name|kind/name]': {
230
- desc: 'Scope name or kind/name for scoped resources'
231
- },
232
- '-q, --query [RSQL query]': {
233
- desc: 'RSQL-formatted query to search for filters that match specific parameters'
234
- },
235
- '--title [title]': {
236
- desc: 'Title of resource(s) to fetch'
237
- },
238
- '--attribute [key=value]': {
239
- desc: 'Attribute in key=value pair format to filter by'
240
- },
241
- '--tag [tag]': {
242
- desc: 'Tag of resource(s) to fetch'
243
- },
244
- '--team [guid|name]': 'The team name or guid to use',
245
- '--no-owner': 'Returns resources which do not have an owner',
246
- '--language=[langCode]': {
247
- desc: `Show the language detail of the retruned object. One of: * | Comma Separated values of ${_types.LanguageTypes.French} | ${_types.LanguageTypes.US} | ${_types.LanguageTypes.German} | ${_types.LanguageTypes.Portugese}`
248
- },
249
- '--languageDefinition=[langCode]': {
250
- desc: `Show the language definition constraint of the returned object. One of: Comma Separated values of ${_types.LanguageTypes.French} | ${_types.LanguageTypes.US} | ${_types.LanguageTypes.German} | ${_types.LanguageTypes.Portugese}`
251
- }
252
- }
253
- };
254
-
255
- /**
256
- * Gets the resource field names to be shown when outputting the resource as a table.
257
- * These names are to be assigned to the api-server HTTP GET request's "fields" query param.
258
- * @param def The resource definition providing the columns to be shown in the outputed table.
259
- * @returns Returns a set set of field names.
260
- */
261
- function getFieldSetFromDefinitionColumns(def) {
262
- var _def$cli, _def$cli$spec, _def$cli$spec$columns;
263
- const fieldSet = new Set();
264
- (_def$cli = def.cli) === null || _def$cli === void 0 ? void 0 : (_def$cli$spec = _def$cli.spec) === null || _def$cli$spec === void 0 ? void 0 : (_def$cli$spec$columns = _def$cli$spec.columns) === null || _def$cli$spec$columns === void 0 ? void 0 : _def$cli$spec$columns.forEach(column => {
265
- let fieldName = column.jsonPath;
266
- if (fieldName.startsWith('.')) {
267
- fieldName = fieldName.substring(1);
268
- }
269
- fieldSet.add(fieldName);
270
- });
271
- return fieldSet;
272
- }
@@ -1,290 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validateFrequency = exports.prompts = exports.localhost = exports.agents = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
- var _ApiServerClient = require("../../common/ApiServerClient");
10
- var _basicPrompts = require("../../common/basicPrompts");
11
- var _CoreConfigController = require("../../common/CoreConfigController");
12
- var _DefinitionsManager = require("../../common/DefinitionsManager");
13
- var _PlatformClient = require("../../common/PlatformClient");
14
- var _CliConfigManager = require("../../common/CliConfigManager");
15
- var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
16
- var _types = require("../../common/types");
17
- var _utils = require("../../common/utils");
18
- var apigeeXAgents = _interopRequireWildcard(require("./apigeexAgents"));
19
- var awsAgents = _interopRequireWildcard(require("./awsAgents"));
20
- var awsSaaSAgents = _interopRequireWildcard(require("./awsSaasAgents"));
21
- var gitHubAgents = _interopRequireWildcard(require("./gitHubSaasAgents"));
22
- var gitLabAgents = _interopRequireWildcard(require("./gitLabAgents"));
23
- var azureAgents = _interopRequireWildcard(require("./azureAgents"));
24
- var edgeAgents = _interopRequireWildcard(require("./edgeAgents"));
25
- var apigeeSaaSAgents = _interopRequireWildcard(require("./apigeexSaasAgents"));
26
- var helpers = _interopRequireWildcard(require("./helpers"));
27
- var istioAgents = _interopRequireWildcard(require("./istioAgents"));
28
- var azureSaasAgents = _interopRequireWildcard(require("./azureSaasAgents"));
29
- var kafkaAgents = _interopRequireWildcard(require("./kafkaAgents"));
30
- var swaggerHubAgents = _interopRequireWildcard(require("./swaggerHubSaasAgents"));
31
- var graylogAgent = _interopRequireWildcard(require("./graylogAgent"));
32
- var ibmAPIConnectAgent = _interopRequireWildcard(require("./ibmAPIConnectAgents"));
33
- var softwareAGWebMethodsAgent = _interopRequireWildcard(require("./softwareAGWebMethodsAgents"));
34
- var traceableAgent = _interopRequireWildcard(require("./traceableAgents"));
35
- var traceableSaaSAgents = _interopRequireWildcard(require("./traceableSaasAgents"));
36
- var platform = _interopRequireWildcard(require("./platform"));
37
- var backstageAgent = _interopRequireWildcard(require("./backstageAgents"));
38
- var sapApiPortalAgent = _interopRequireWildcard(require("./sapApiPortalAgents"));
39
- var wso2Agents = _interopRequireWildcard(require("./wso2Agents"));
40
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
41
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
42
- const {
43
- log
44
- } = (0, _snooplogg.default)('engage: install: agents');
45
- const localhost = exports.localhost = 'localhost';
46
- const prompts = exports.prompts = {
47
- hostedAgentOption: 'Will this be an embedded agent',
48
- selectGatewayType: 'Select the type of gateway you want to connect'
49
- };
50
- const agentInstallFlows = {
51
- [_types.GatewayTypes.EDGE_GATEWAY]: edgeAgents.EdgeInstallMethods,
52
- [_types.GatewayTypes.EDGE_GATEWAY_ONLY]: edgeAgents.EdgeGWOnlyInstallMethods,
53
- [_types.GatewayTypes.AWS_GATEWAY]: awsAgents.AWSInstallMethods,
54
- [_types.GatewayTypes.APIGEEX_GATEWAY]: apigeeXAgents.ApigeeXInstallMethods,
55
- [_types.GatewayTypes.GITLAB]: gitLabAgents.GitLabInstallMethods,
56
- [_types.GatewayTypes.AZURE_GATEWAY]: azureAgents.AzureInstallMethods,
57
- [_types.GatewayTypes.AZURE_EVENTHUB]: azureAgents.AzureInstallMethods,
58
- [_types.GatewayTypes.ISTIO]: istioAgents.IstioInstallMethods,
59
- [_types.GatewayTypes.KAFKA]: kafkaAgents.KafkaInstallMethods,
60
- [_types.GatewayTypes.GRAYLOG]: graylogAgent.GraylogInstallMethods,
61
- [_types.GatewayTypes.IBMAPICONNECT]: ibmAPIConnectAgent.IBMAPIConnectInstallMethods,
62
- [_types.GatewayTypes.SOFTWAREAGWEBMETHODS]: softwareAGWebMethodsAgent.SoftwareAGWebMethodsInstallMethods,
63
- [_types.GatewayTypes.TRACEABLE]: traceableAgent.TraceableInstallMethods,
64
- [_types.GatewayTypes.BACKSTAGE]: backstageAgent.BackstageInstallMethods,
65
- [_types.GatewayTypes.SAPAPIPORTAL]: sapApiPortalAgent.SAPAPIPortalInstallMethods,
66
- [_types.GatewayTypes.WSO2]: wso2Agents.WSO2InstallMethods
67
- };
68
- const saasAgentInstallFlows = {
69
- [_types.SaaSGatewayTypes.AWS_GATEWAY]: awsSaaSAgents.AWSSaaSInstallMethods,
70
- [_types.SaaSGatewayTypes.GITHUB]: gitHubAgents.GitHubSaaSInstallMethods,
71
- [_types.SaaSGatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods,
72
- [_types.SaaSGatewayTypes.SWAGGERHUB]: swaggerHubAgents.SwaggerHubSaaSInstallMethods,
73
- [_types.GatewayTypes.AZURE_GATEWAY]: azureSaasAgents.AzureSaaSInstallMethods,
74
- [_types.GatewayTypes.AZURE_EVENTHUB]: azureSaasAgents.AzureSaaSInstallMethods,
75
- [_types.GatewayTypes.TRACEABLE]: traceableSaaSAgents.TraceableSaaSInstallMethods
76
- };
77
- const createConfigBackup = async (configFiles, gatewayType) => {
78
- // If current configurations exist, back them up
79
- const configsExist = await helpers.createBackUpConfigs(configFiles);
80
- if (configsExist) {
81
- console.log(`\nCreated configuration backups for ${gatewayType}`);
82
- }
83
- };
84
- const determineRegion = async region => {
85
- let configurationRegion = (await (0, _utils.getConfig)())[_CliConfigManager.CliConfigKeys.REGION];
86
- if (region) {
87
- return region.toString();
88
- }
89
- return configurationRegion ? configurationRegion : _types.Regions.US;
90
- };
91
- const agents = exports.agents = {
92
- action: async function ({
93
- argv,
94
- console
95
- }) {
96
- const {
97
- baseUrl,
98
- account,
99
- region,
100
- apicDeployment,
101
- cache,
102
- axwayManaged
103
- } = argv;
104
- let isCmdError = false;
105
- const render = new _Renderer.default(console);
106
- try {
107
- var _accountInfo$roles, _accountInfo$roles2;
108
- // initialize clients
109
- const apiServerClient = new _ApiServerClient.ApiServerClient({
110
- baseUrl,
111
- account,
112
- region,
113
- useCache: cache
114
- });
115
- const platformClient = new _PlatformClient.PlatformClient({
116
- baseUrl,
117
- account,
118
- region
119
- });
120
- const defsManager = await new _DefinitionsManager.DefinitionsManager(apiServerClient).init();
121
- // Verify account has permission to create an environment and service account.
122
- const accountInfo = await platformClient.getAccountInfo();
123
- const isCentralAdmin = accountInfo === null || accountInfo === void 0 ? void 0 : (_accountInfo$roles = accountInfo.roles) === null || _accountInfo$roles === void 0 ? void 0 : _accountInfo$roles.includes(_CoreConfigController.AccountRole.ApiCentralAdmin);
124
- const isPlatformAdmin = accountInfo === null || accountInfo === void 0 ? void 0 : (_accountInfo$roles2 = accountInfo.roles) === null || _accountInfo$roles2 === void 0 ? void 0 : _accountInfo$roles2.includes(_CoreConfigController.AccountRole.PlatformAdmin);
125
- checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render);
126
-
127
- // helper text
128
- console.log(_chalk.default.gray(`This command configures and installs the agents so that you can manage your gateway environment within the Amplify Platform.\n`));
129
- let installConfig = new _types.AgentInstallConfig();
130
- installConfig.centralConfig.apiServerClient = apiServerClient;
131
- installConfig.centralConfig.definitionManager = defsManager;
132
- installConfig.centralConfig.axwayManaged = !!axwayManaged;
133
- let orgRegion = '';
134
- orgRegion = region;
135
-
136
- // if region cmd arg is not passed in, then consider the region from the account info
137
- if (region === undefined) {
138
- orgRegion = accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.org.region;
139
- }
140
-
141
- // top priority is region option on command line, second priority is region from config file, default is US
142
- installConfig.centralConfig.region = await determineRegion(orgRegion);
143
- let gatewayTypeChoices = [];
144
- Object.values(_types.GatewayTypes).forEach(v => gatewayTypeChoices.push(v));
145
- Object.values(_types.SaaSGatewayTypes).filter(v => v !== _types.SaaSGatewayTypes.AWS_GATEWAY && v !== _types.SaaSGatewayTypes.APIGEEX_GATEWAY && v !== _types.SaaSGatewayTypes.TRACEABLE).forEach(v => gatewayTypeChoices.push(v));
146
- let gatewayChoices = gatewayTypeChoices.sort().filter(v => v !== _types.GatewayTypes.EDGE_GATEWAY_ONLY);
147
- let gatewayType = await (0, _basicPrompts.askList)({
148
- msg: prompts.selectGatewayType,
149
- choices: gatewayChoices
150
- });
151
-
152
- // Check for central environments if Traceable is selected (before asking about hosted vs on-premise)
153
- if (gatewayType === _types.GatewayTypes.TRACEABLE) {
154
- const centralEnvs = await helpers.getCentralEnvironments(installConfig.centralConfig.apiServerClient, installConfig.centralConfig.definitionManager);
155
- if (!centralEnvs || centralEnvs.length === 0) {
156
- console.log(_chalk.default.red('Installation cannot proceed: No Engage environments are available for mapping.'));
157
- console.log(_chalk.default.yellow('Please create at least one Engage environment before installing the Traceable agent.'));
158
- console.log(_chalk.default.gray('You can create an environment using: axway engage create environment'));
159
- process.exit(1);
160
- }
161
- }
162
-
163
- // if this check gets bigger, may think about an array of agents that can be both ground and embedded until ground agents become obsolete
164
- if (gatewayType === _types.GatewayTypes.AWS_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_EVENTHUB || gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY || gatewayType === _types.GatewayTypes.TRACEABLE) {
165
- // hosted vs on premise
166
- installConfig.switches.isHostedInstall = (await (0, _basicPrompts.askList)({
167
- msg: prompts.hostedAgentOption,
168
- choices: _types.YesNoChoices,
169
- default: _types.YesNo.Yes
170
- })) === _types.YesNo.Yes;
171
- }
172
- if (gatewayType === _types.SaaSGatewayTypes.GITHUB || gatewayType === _types.SaaSGatewayTypes.SWAGGERHUB) {
173
- installConfig.switches.isHostedInstall = true;
174
- }
175
-
176
- // if gateway type is edge ask Gateway only or not
177
- if (gatewayType === _types.GatewayTypes.EDGE_GATEWAY) {
178
- installConfig.switches.isGatewayOnly = false;
179
- gatewayType = await edgeAgents.askIsGatewayOnlyMode();
180
- }
181
- installConfig.switches.isGatewayOnly = gatewayType === _types.GatewayTypes.EDGE_GATEWAY_ONLY;
182
- installConfig.gatewayType = gatewayType;
183
- let agentInstallFlow = agentInstallFlows[installConfig.gatewayType];
184
- if (installConfig.switches.isHostedInstall) {
185
- agentInstallFlow = saasAgentInstallFlows[installConfig.gatewayType];
186
- }
187
-
188
- // Create the object of GatewayTypes -> BundleType functions
189
- installConfig.bundleType = await agentInstallFlow.GetBundleType(installConfig.gatewayType);
190
- installConfig.switches.isDaEnabled = installConfig.bundleType === _types.BundleType.ALL_AGENTS || installConfig.bundleType === _types.BundleType.DISCOVERY;
191
- installConfig.switches.isTaEnabled = installConfig.bundleType === _types.BundleType.ALL_AGENTS || installConfig.bundleType === _types.BundleType.TRACEABILITY || installConfig.bundleType === _types.BundleType.TRACEABILITY_OFFLINE;
192
-
193
- // Create the object of GatewayTypes -> BundleType functions
194
- installConfig.deploymentType = await agentInstallFlow.GetDeploymentType();
195
- installConfig.switches.isHelmInstall = installConfig.deploymentType === _types.AgentConfigTypes.HELM;
196
- installConfig.switches.isDockerInstall = installConfig.deploymentType === _types.AgentConfigTypes.DOCKERIZED;
197
- installConfig.switches.isBinaryInstall = installConfig.deploymentType === _types.AgentConfigTypes.BINARIES;
198
-
199
- // Get the version of the agents from jfrog, not needed in hosted install
200
- await getAgentVersions(agentInstallFlow, installConfig);
201
-
202
- // if EDGE_GATEWAY or EDGE_GATEWAY_ONLY and isDaEnabled, ask if the organization structure should replicate
203
- if ((gatewayType === _types.GatewayTypes.EDGE_GATEWAY || gatewayType === _types.GatewayTypes.EDGE_GATEWAY_ONLY) && installConfig.switches.isDaEnabled) {
204
- installConfig.switches.isOrgRep = await edgeAgents.askOrganizationReplication();
205
- }
206
-
207
- // get platform connectivity
208
- installConfig.centralConfig = await platform.getCentralConfig(apiServerClient, platformClient, defsManager, apicDeployment, installConfig);
209
-
210
- // Create the object of GatewayTypes -> GatewayConnectivity functions
211
- installConfig.gatewayConfig = await agentInstallFlow.AskGatewayQuestions(installConfig, apiServerClient, defsManager);
212
-
213
- // create the Identity Provider configuration
214
- if (agentInstallFlow.AddIDP) {
215
- installConfig.idpConfig = await helpers.idpTestables.addIdentityProvider();
216
- }
217
-
218
- // traceability options
219
- if (installConfig.switches.isTaEnabled && !installConfig.switches.isHostedInstall) {
220
- installConfig.traceabilityConfig = await platform.getTraceabilityConfig(installConfig);
221
- }
222
-
223
- // create backup
224
- await createConfigBackup(agentInstallFlow.ConfigFiles, agentInstallFlow.GatewayDisplay);
225
-
226
- // run any install preprocess steps
227
- installConfig = await finishInstall(agentInstallFlow, installConfig, apiServerClient, platformClient, defsManager);
228
-
229
- // finalize gateway setup and output
230
- await agentInstallFlow.FinalizeGatewayInstall(installConfig, apiServerClient, defsManager);
231
- } catch (e) {
232
- log('command error', e);
233
- isCmdError = true;
234
- render.anyError(e);
235
- } finally {
236
- log('command complete');
237
- if (isCmdError) process.exit(1);
238
- // not sure why explicit exit is needed, seems like download is causing it to hang for 10-20 sec
239
- process.exit(0);
240
- }
241
- },
242
- desc: 'Amplify API Gateway / Amazon API Gateway / Azure API Gateway / Istio / Apigee X Gateway / GitHub / GitLab / Kafka / SwaggerHub/ Software AG WebMethods',
243
- options: {
244
- ..._types.commonCmdArgsDescription
245
- }
246
- };
247
- async function getAgentVersions(agentInstallFlow, installConfig) {
248
- if (agentInstallFlow.AgentNameMap && !installConfig.switches.isHostedInstall && installConfig.switches.isDaEnabled) {
249
- installConfig.daVersion = await helpers.getLatestAgentVersion(agentInstallFlow.AgentNameMap[_types.AgentTypes.da]);
250
- }
251
- if (agentInstallFlow.AgentNameMap && !installConfig.switches.isHostedInstall && installConfig.switches.isTaEnabled) {
252
- installConfig.taVersion = await helpers.getLatestAgentVersion(agentInstallFlow.AgentNameMap[_types.AgentTypes.ta]);
253
- }
254
- }
255
- async function finishInstall(agentInstallFlow, installConfig, apiServerClient, platformClient, defsManager) {
256
- if (agentInstallFlow.InstallPreprocess) installConfig = await agentInstallFlow.InstallPreprocess(installConfig);
257
-
258
- // finalize Platform setup, only for non-hosted agents
259
- if (!installConfig.switches.isHostedInstall) {
260
- installConfig = await platform.finalizeCentralInstall(apiServerClient, platformClient, defsManager, installConfig);
261
- }
262
- return installConfig;
263
- }
264
- function checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render) {
265
- if (!isCentralAdmin || !isPlatformAdmin) {
266
- if (!accountInfo || accountInfo.isPlatform) {
267
- render.error('Error: Not authorized. Account must be assigned the roles: Platform Admin, Engage Admin');
268
- } else {
269
- render.error('Error: Not authorized. "Service Account" must be authorized with a user account with "Tooling Credentials" assigned the roles: Platform Admin, Engage Admin');
270
- render.error('See: https://docs.axway.com/bundle/axwaycli-open-docs/page/docs/authentication/index.html#service-account-with-username-password');
271
- }
272
- process.exit(1);
273
- }
274
- }
275
- const validateFrequency = () => input => {
276
- let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
277
- if (typeof val === 'string') {
278
- return val;
279
- }
280
- let r = input.toString().match(/^(\d*)m/);
281
- if (r) {
282
- // only minutes
283
- let mins = r[1];
284
- if (parseInt(mins, 10) < 30) {
285
- return 'Minimum frequency is 30m';
286
- }
287
- }
288
- return true;
289
- };
290
- exports.validateFrequency = validateFrequency;