@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.testables = exports.askBundleType = exports.SwaggerHubSaaSInstallMethods = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
- var _basicPrompts = require("../../common/basicPrompts");
10
- var _types = require("../../common/types");
11
- var helpers = _interopRequireWildcard(require("./helpers"));
12
- var _crypto = _interopRequireDefault(require("crypto"));
13
- 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); }
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
- const {
19
- log
20
- } = (0, _snooplogg.default)('central: install: agents: saas');
21
- class DataplaneConfig {
22
- constructor(type) {
23
- _defineProperty(this, "type", void 0);
24
- this.type = type || "";
25
- }
26
- }
27
- class SwaggerHubDataplaneConfig extends DataplaneConfig {
28
- constructor(owner, filter) {
29
- super("SwaggerHub");
30
- _defineProperty(this, "owner", void 0);
31
- _defineProperty(this, "filter", void 0);
32
- this.owner = owner;
33
- this.filter = filter;
34
- }
35
- }
36
- class SwaggerHubFilterConfig {
37
- constructor(visibility, publication) {
38
- _defineProperty(this, "visibility", void 0);
39
- _defineProperty(this, "publication", void 0);
40
- this.visibility = visibility;
41
- this.publication = publication;
42
- }
43
- }
44
- var SwaggerHubFilterVisibility = /*#__PURE__*/function (SwaggerHubFilterVisibility) {
45
- SwaggerHubFilterVisibility["Both"] = "Both";
46
- SwaggerHubFilterVisibility["Public"] = "Public";
47
- SwaggerHubFilterVisibility["Private"] = "Private";
48
- return SwaggerHubFilterVisibility;
49
- }(SwaggerHubFilterVisibility || {});
50
- var SwaggerHubFilterPublication = /*#__PURE__*/function (SwaggerHubFilterPublication) {
51
- SwaggerHubFilterPublication["Both"] = "Both";
52
- SwaggerHubFilterPublication["Published"] = "Published";
53
- SwaggerHubFilterPublication["UnPublished"] = "UnPublished";
54
- return SwaggerHubFilterPublication;
55
- }(SwaggerHubFilterPublication || {});
56
- class SaasAgentValues {
57
- constructor() {
58
- _defineProperty(this, "frequencyDA", void 0);
59
- _defineProperty(this, "queueDA", void 0);
60
- _defineProperty(this, "frequencyTA", void 0);
61
- _defineProperty(this, "dataplaneConfig", void 0);
62
- _defineProperty(this, "centralConfig", void 0);
63
- _defineProperty(this, "owner", void 0);
64
- _defineProperty(this, "visibility", void 0);
65
- _defineProperty(this, "publication", void 0);
66
- this.frequencyDA = '';
67
- this.queueDA = false;
68
- this.frequencyTA = '';
69
- this.dataplaneConfig = new DataplaneConfig();
70
- this.centralConfig = new _types.CentralAgentConfig();
71
- this.owner = '';
72
- this.visibility = SwaggerHubFilterVisibility.Both;
73
- this.publication = SwaggerHubFilterPublication.Both;
74
- }
75
- }
76
- class SaasSwaggerHubAgentValues extends SaasAgentValues {
77
- constructor() {
78
- super();
79
- _defineProperty(this, "apiKey", void 0);
80
- this.apiKey = '';
81
- }
82
- getAccessData() {
83
- let data = JSON.stringify({
84
- apiKey: this.apiKey
85
- });
86
- return data;
87
- }
88
- }
89
-
90
- // ConfigFiles - all the config file that are used in the setup
91
- const ConfigFiles = {};
92
-
93
- // SwaggerHub SaaSPrompts - all SwaggerHub Saas prompts to the user for input
94
- const SaasPrompts = {
95
- API_KEY: 'Enter the SwaggerHub API Key the agent will use',
96
- ORGANIZATION_OWNER: 'Enter the SwaggerHub Organization Owner the agent will use',
97
- API_VISIBILITY: 'Enter the visibility of the APIs to be discovered (Optional).',
98
- API_PUBLICATION: 'Enter the publication status of APIs to be discovered (Optional).',
99
- DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
100
- QUEUE: 'Do you want to discover immediately after installation'
101
- };
102
- const askBundleType = async () => {
103
- //SwaggerHub agent has only DA
104
- return _types.BundleType.DISCOVERY;
105
- };
106
- exports.askBundleType = askBundleType;
107
- const askConfigType = async () => {
108
- return _types.AgentConfigTypes.HOSTED;
109
- };
110
- const askForSwaggerHubCredentials = async hostedAgentValues => {
111
- log("gathering access details for SwaggerHub");
112
- hostedAgentValues.apiKey = await (0, _basicPrompts.askInput)({
113
- msg: SaasPrompts.API_KEY,
114
- defaultValue: hostedAgentValues.apiKey !== '' ? hostedAgentValues.apiKey : undefined
115
- });
116
- return hostedAgentValues;
117
- };
118
- const validateFrequency = () => input => {
119
- let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
120
- if (typeof val === "string") {
121
- return val;
122
- }
123
- let r = input.toString().match(/^(\d*)m/);
124
- if (r) {
125
- // only minutes
126
- let mins = r[1];
127
- if (parseInt(mins, 10) < 30) {
128
- return "Minimum frequency is 30m";
129
- }
130
- }
131
- return true;
132
- };
133
-
134
- // @ts-ignore
135
- const gatewayConnectivity = async installConfig => {
136
- console.log('\nCONNECTION TO SwaggerHub API GATEWAY:');
137
- console.log(_chalk.default.gray("The Discovery Agent needs to connect to the SwaggerHub API Gateway to discover API's for publishing to Amplify Central"));
138
-
139
- // DeploymentType
140
- let hostedAgentValues = new SaasAgentValues();
141
- if (installConfig.gatewayType === _types.SaaSGatewayTypes.SWAGGERHUB) {
142
- // SwaggerHub connection details
143
- hostedAgentValues = new SaasSwaggerHubAgentValues();
144
- hostedAgentValues = await askForSwaggerHubCredentials(hostedAgentValues);
145
- }
146
-
147
- // Ask to queue discovery now
148
- log("getting the frequency and if the agent should run now");
149
- console.log(_chalk.default.gray("\n00d00h00m format, where 30m = 30 minutes, 1h = 1 hour, 7d = 7 days, and 7d1h30m = 7 days 1 hour and 30 minutes. Minimum of 30m."));
150
- hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
151
- msg: SaasPrompts.DA_FREQUENCY,
152
- validate: validateFrequency(),
153
- allowEmptyInput: true
154
- });
155
- hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
156
- msg: SaasPrompts.QUEUE,
157
- default: _types.YesNo.No,
158
- choices: _types.YesNoChoices
159
- })) === _types.YesNo.Yes;
160
-
161
- // get swaggerhub organization owner
162
- hostedAgentValues.owner = await (0, _basicPrompts.askInput)({
163
- msg: SaasPrompts.ORGANIZATION_OWNER,
164
- defaultValue: hostedAgentValues.owner !== '' ? hostedAgentValues.owner : undefined
165
- });
166
-
167
- // get visility of APIs to be discovered
168
- hostedAgentValues.visibility = await (0, _basicPrompts.askList)({
169
- msg: SaasPrompts.API_VISIBILITY,
170
- default: SwaggerHubFilterVisibility.Both,
171
- choices: [{
172
- name: SwaggerHubFilterVisibility.Both,
173
- value: SwaggerHubFilterVisibility.Both
174
- }, {
175
- name: SwaggerHubFilterVisibility.Public,
176
- value: SwaggerHubFilterVisibility.Public
177
- }, {
178
- name: SwaggerHubFilterVisibility.Private,
179
- value: SwaggerHubFilterVisibility.Private
180
- }]
181
- });
182
-
183
- // get publication status of APIs to be discovered
184
- hostedAgentValues.publication = await (0, _basicPrompts.askList)({
185
- msg: SaasPrompts.API_PUBLICATION,
186
- default: SwaggerHubFilterPublication.Both,
187
- choices: [{
188
- name: SwaggerHubFilterPublication.Both,
189
- value: SwaggerHubFilterPublication.Both
190
- }, {
191
- name: SwaggerHubFilterPublication.Published,
192
- value: SwaggerHubFilterPublication.Published
193
- }, {
194
- name: SwaggerHubFilterPublication.UnPublished,
195
- value: SwaggerHubFilterPublication.UnPublished
196
- }]
197
- });
198
- return hostedAgentValues;
199
- };
200
- const generateOutput = async installConfig => {
201
- return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
202
- };
203
- const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
204
- var _dataplaneRes$securit, _dataplaneRes$securit2;
205
- // grab key from data plane resource
206
- let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
207
- let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
208
- if (key === "" || hash === "") {
209
- throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
210
- }
211
- console.log(hostedAgentValues.getAccessData());
212
- let encData = _crypto.default.publicEncrypt({
213
- key: key,
214
- padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
215
- oaepHash: hash
216
- }, Buffer.from(hostedAgentValues.getAccessData()));
217
- return encData.toString("base64");
218
- };
219
- const completeInstall = async (installConfig, apiServerClient, defsManager) => {
220
- /**
221
- * Create agent resources
222
- */
223
- console.log("\n");
224
- let swaggerHubAgentValues = installConfig.gatewayConfig;
225
-
226
- // create the environment, if necessary
227
- installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
228
- axwayManaged: installConfig.centralConfig.axwayManaged,
229
- production: installConfig.centralConfig.production
230
- }) : installConfig.centralConfig.ampcEnvInfo.name;
231
- if (installConfig.gatewayType === _types.SaaSGatewayTypes.SWAGGERHUB) {
232
- swaggerHubAgentValues.dataplaneConfig = new SwaggerHubDataplaneConfig(swaggerHubAgentValues.owner, new SwaggerHubFilterConfig(swaggerHubAgentValues.visibility, swaggerHubAgentValues.publication));
233
- }
234
-
235
- // create the data plane resource
236
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], swaggerHubAgentValues.dataplaneConfig);
237
- // create data plane secret resource
238
- try {
239
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(swaggerHubAgentValues, dataplaneRes));
240
- } catch (error) {
241
- console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
242
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
243
- await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
244
- } else {
245
- await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
246
- }
247
- return;
248
- }
249
-
250
- // create discovery agent resource
251
- installConfig.centralConfig.daAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.da, _types.AgentTypes.da, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Discovery Agent", dataplaneRes.name, swaggerHubAgentValues.frequencyDA, swaggerHubAgentValues.queueDA);
252
- console.log(await generateOutput(installConfig));
253
- };
254
- const SwaggerHubSaaSInstallMethods = exports.SwaggerHubSaaSInstallMethods = {
255
- GetBundleType: askBundleType,
256
- GetDeploymentType: askConfigType,
257
- AskGatewayQuestions: gatewayConnectivity,
258
- FinalizeGatewayInstall: completeInstall,
259
- ConfigFiles: [],
260
- AgentNameMap: {
261
- [_types.AgentTypes.da]: _types.AgentNames.SWAGGERHUB_DA
262
- },
263
- GatewayDisplay: _types.SaaSGatewayTypes.SWAGGERHUB
264
- };
265
-
266
- // These are the items that are not exported, but need to be for testing
267
- const testables = exports.testables = {
268
- SaasAgentValues,
269
- SaasSwaggerHubAgentValues,
270
- SaasPrompts,
271
- ConfigFiles
272
- };
@@ -1,257 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.gatewayConnectivity = exports.completeInstall = exports.askTraceableRegion = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.TraceableInstallMethods = exports.ConfigFiles = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
- var _Kubectl = require("../../common/Kubectl");
10
- var _basicPrompts = require("../../common/basicPrompts");
11
- var _inputs = require("./helpers/inputs");
12
- var _types = require("../../common/types");
13
- var _utils = require("../../common/utils");
14
- var helpers = _interopRequireWildcard(require("./helpers"));
15
- var _traceableTemplates = require("./helpers/templates/traceableTemplates");
16
- 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); }
17
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
- // @ts-ignore
19
- const {
20
- log
21
- } = (0, _snooplogg.default)('central: install: agents: Traceable');
22
- const caImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.TRACEABLE_CA}`;
23
- const amplifyAgentsNs = exports.amplifyAgentsNs = 'amplify-agents';
24
-
25
- // ConfigFiles - all the config file that are used in the setup
26
- const ConfigFiles = exports.ConfigFiles = {
27
- helmOverride: 'agent-overrides.yaml',
28
- agentEnvVars: `${helpers.configFiles.AGENT_ENV_VARS}`
29
- };
30
-
31
- // TraceablePrompts - prompts for user inputs
32
- const prompts = {
33
- configTypeMsg: 'Select the mode of installation',
34
- agentNamespace: 'Enter the namespace to use for the Amplify Traceable Agents',
35
- enterToken: 'Enter the token that the agent will use',
36
- enterRegion: 'Enter the region that the agent will use',
37
- enterEnvironments: 'Enter a Traceable environment',
38
- enterMoreEnvironments: 'Do you want to enter another mapping?',
39
- selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Traceable environment',
40
- environmentsDescription: 'Configure a mapping of Traceable environment to Engage environment that the agent will use'
41
- };
42
- const askBundleType = async () => {
43
- return _types.BundleType.TRACEABILITY;
44
- };
45
- exports.askBundleType = askBundleType;
46
- const askConfigType = async () => {
47
- return await (0, _basicPrompts.askList)({
48
- msg: prompts.configTypeMsg,
49
- choices: [_types.AgentConfigTypes.DOCKERIZED, _types.AgentConfigTypes.HELM]
50
- });
51
- };
52
-
53
- //
54
- // Questions for the configuration of Traceable agent
55
- //
56
- exports.askConfigType = askConfigType;
57
- const askToken = async () => await (0, _basicPrompts.askInput)({
58
- msg: prompts.enterToken,
59
- allowEmptyInput: false
60
- });
61
- const askTraceableRegion = async () => {
62
- return await (0, _basicPrompts.askList)({
63
- msg: prompts.enterRegion,
64
- choices: Object.entries(_types.TraceableRegionType).reduce((accumulator, curr) => {
65
- return accumulator.concat({
66
- name: curr[0],
67
- value: curr[1]
68
- });
69
- }, []),
70
- default: _types.TraceableRegionType.US
71
- });
72
- };
73
- exports.askTraceableRegion = askTraceableRegion;
74
- const askEnvironments = async (centralEnvs, traceableAgentValues, excludeEnvironment) => {
75
- // Filter out the already-selected agent installation environment
76
- if (excludeEnvironment) {
77
- centralEnvs = centralEnvs.filter(env => env.name !== excludeEnvironment);
78
- }
79
-
80
- // If no central environments are available, exit the installation
81
- if (centralEnvs.length === 0) {
82
- console.log(_chalk.default.red('Installation cannot proceed: No Engage environments are available for mapping.'));
83
- console.log(_chalk.default.yellow('Please create at least one Engage environment before installing the Traceable agent.'));
84
- console.log(_chalk.default.gray('You can create an environment using: axway engage create environment'));
85
- process.exit(1);
86
- }
87
- let askEnvs = true;
88
- let envs = [];
89
- let mappedCentralEnvs = [];
90
- console.log(_chalk.default.gray(prompts.environmentsDescription));
91
- while (askEnvs) {
92
- const env = await (0, _basicPrompts.askInput)({
93
- msg: prompts.enterEnvironments,
94
- allowEmptyInput: true
95
- });
96
- if (envs.length === 0 && (!env || env.toString().trim() === "")) {
97
- break;
98
- }
99
- if (env && env.toString().trim() !== "") {
100
- envs.push(env);
101
- }
102
- const centralMappingEnv = await (0, _basicPrompts.askList)({
103
- msg: prompts.selectCentralMappingEnvironment,
104
- choices: centralEnvs.map(e => e.name)
105
- });
106
- if (centralMappingEnv && centralMappingEnv.toString().trim() !== "") {
107
- mappedCentralEnvs.push(centralMappingEnv);
108
- }
109
- // Remove the selected environment from available choices for next iteration
110
- centralEnvs = centralEnvs.filter(env => env.name !== centralMappingEnv);
111
-
112
- // Only ask to continue if there are remaining central environments
113
- if (centralEnvs.length > 0) {
114
- askEnvs = (await (0, _basicPrompts.askList)({
115
- msg: prompts.enterMoreEnvironments,
116
- default: _types.YesNo.No,
117
- choices: _types.YesNoChoices
118
- })) === _types.YesNo.Yes;
119
- } else {
120
- askEnvs = false; // Auto-stop when no environments remain
121
- }
122
- }
123
- traceableAgentValues.environments = envs;
124
- traceableAgentValues.centralEnvironments = mappedCentralEnvs;
125
- };
126
- const gatewayConnectivity = async installConfig => {
127
- let traceableAgentValues = new _traceableTemplates.TraceableAgentValues();
128
- if (installConfig.switches.isHelmInstall) {
129
- console.log(_chalk.default.gray(`The Amplify Traceable Agent needs to be deployed to your Kubernetes cluster to discover APIs for publishing to Amplify Central.`));
130
- const {
131
- error
132
- } = await _Kubectl.kubectl.isInstalled();
133
- if (error) {
134
- throw new Error(`Kubectl is required to fill out the following prompts. It appears to be missing or misconfigured.\n${error}`);
135
- }
136
- traceableAgentValues.namespace = await (0, _inputs.askNamespace)(prompts.agentNamespace, amplifyAgentsNs);
137
- }
138
- if (installConfig.switches.isDockerInstall) {
139
- console.log('\nCONNECTION TO TRACEABLE API GATEWAY:');
140
- console.log(_chalk.default.gray("The Discovery Agent needs to connect to the Traceable API Gateway to discover API's for publishing to Amplify Central."));
141
- }
142
- traceableAgentValues.traceableToken = await askToken();
143
- traceableAgentValues.traceableRegion = await askTraceableRegion();
144
- await helpers.getCentralEnvironments(installConfig.centralConfig.apiServerClient, installConfig.centralConfig.definitionManager).then(async envs => {
145
- if (envs) {
146
- var _installConfig$centra;
147
- // Pass the already-selected agent installation environment to exclude it from mapping choices
148
- const agentInstallEnv = (_installConfig$centra = installConfig.centralConfig.ampcEnvInfo) === null || _installConfig$centra === void 0 ? void 0 : _installConfig$centra.name;
149
- await askEnvironments(envs, traceableAgentValues, agentInstallEnv);
150
- }
151
- });
152
- return traceableAgentValues;
153
- };
154
- exports.gatewayConnectivity = gatewayConnectivity;
155
- const dockerSuccessMsg = installConfig => {
156
- let dockerInfo;
157
- const runAgentLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.AGENT_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
158
- const runAgentWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.AGENT_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
159
- const startAgentLinuxMsg = `\nStart the Traceable Agent on a Linux based machine`;
160
- const startAgentWinMsg = `\nStart the Traceable Agent on a Windows machine`;
161
- if (installConfig.switches.isTaEnabled) {
162
- dockerInfo = `To utilize the agent, pull the latest Docker image and run it using the appropriate supplied environment file, (${helpers.configFiles.AGENT_ENV_VARS}):`;
163
- console.log(_chalk.default.whiteBright(dockerInfo), '\n');
164
- const caImageVersion = `${caImage}:${installConfig.taVersion}`;
165
- console.log(_chalk.default.white('Pull the latest image of the Agent:'));
166
- console.log(_chalk.default.cyan(`docker pull ${caImageVersion}`));
167
- console.log(_chalk.default.white(_utils.isWindows ? startAgentWinMsg : startAgentLinuxMsg));
168
- console.log(_chalk.default.cyan(_utils.isWindows ? runAgentWinMsg : runAgentLinuxMsg));
169
- console.log('\t', _chalk.default.cyan(`-v /data ${caImageVersion}`), '\n');
170
- }
171
- };
172
- const helmSuccessMsg = namespace => {
173
- console.log(`Traceable Agent override file has been placed at ${process.cwd()}/${ConfigFiles.helmOverride}`);
174
- helpers.helmImageSecretInfo(namespace);
175
- let agentHelmInfo = new Set();
176
- agentHelmInfo.add({
177
- helmReleaseName: 'traceable-agent',
178
- helmChartName: ' axway/traceable-agent',
179
- overrideFileName: ConfigFiles.helmOverride,
180
- imageSecretOverrides: `--set image.pullSecret=<image-pull-secret-name>`
181
- });
182
- helpers.helmInstallInfo('Traceable', namespace, agentHelmInfo);
183
- };
184
- const generateSuccessHelpMsg = installConfig => {
185
- const traceableAgentValues = installConfig.gatewayConfig;
186
- const configType = installConfig.deploymentType;
187
- if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
188
- console.log(_chalk.default.yellow('\nPlease make sure to copy the "private_key.pem" and "public_key.pem" files for the existing service account you selected.'));
189
- }
190
- if (configType === _types.AgentConfigTypes.DOCKERIZED) {
191
- dockerSuccessMsg(installConfig);
192
- } else if (configType === _types.AgentConfigTypes.HELM) {
193
- helmSuccessMsg(traceableAgentValues.namespace.name);
194
- }
195
- console.log('Configuration file(s) have been successfully created.\n');
196
- console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.TRACEABLE}`));
197
- };
198
- const completeInstall = async installConfig => {
199
- // Add final settings to TraceableAgentValues
200
- const traceableAgentValues = installConfig.gatewayConfig;
201
- traceableAgentValues.centralConfig = installConfig.centralConfig;
202
- traceableAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
203
- if (installConfig.switches.isHelmInstall) {
204
- traceableAgentValues.traceableSecret = helpers.amplifyAgentsCredsSecret;
205
- traceableAgentValues.agentKeysSecret = helpers.amplifyAgentsKeysSecret;
206
- if (traceableAgentValues.namespace.isNew) {
207
- await helpers.createNamespace(traceableAgentValues.namespace.name);
208
- }
209
- await helpers.createSecret(traceableAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, async () => {
210
- if (installConfig.centralConfig.ampcDosaInfo.isNew) {
211
- console.log(_chalk.default.yellow(`The secret '${helpers.amplifyAgentsKeysSecret}' will be created with the same "private_key.pem" and "public_key.pem" that was auto generated to create the Service Account.`));
212
- }
213
- await helpers.createAmplifyAgentKeysSecret(traceableAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, 'publicKey', traceableAgentValues.centralConfig.dosaAccount.publicKey, 'privateKey', traceableAgentValues.centralConfig.dosaAccount.privateKey);
214
- });
215
- await helpers.createSecret(traceableAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, async () => {
216
- await createTraceableCredsSecret(traceableAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, traceableAgentValues.traceableToken);
217
- });
218
- }
219
- console.log('Generating the configuration file(s)...');
220
- if (installConfig.switches.isDockerInstall) {
221
- if (installConfig.switches.isTaEnabled) {
222
- (0, _utils.writeTemplates)(ConfigFiles.agentEnvVars, traceableAgentValues, helpers.traceableEnvVarTemplate);
223
- }
224
- } else if (installConfig.switches.isHelmInstall) {
225
- (0, _utils.writeTemplates)(ConfigFiles.helmOverride, traceableAgentValues, helpers.traceableHelmOverrideTemplate);
226
- }
227
- generateSuccessHelpMsg(installConfig);
228
- };
229
- exports.completeInstall = completeInstall;
230
- const createTraceableCredsSecret = async (namespace, secretName, token) => {
231
- const {
232
- error
233
- } = await _Kubectl.kubectl.create('secret', `-n ${namespace} generic ${secretName} \
234
- --from-literal=token=${token} `);
235
- if (error) {
236
- throw Error(error);
237
- }
238
- console.log(`Created ${secretName} in the ${namespace} namespace.`);
239
- };
240
- const TraceableInstallMethods = exports.TraceableInstallMethods = {
241
- GetBundleType: askBundleType,
242
- GetDeploymentType: askConfigType,
243
- AskGatewayQuestions: gatewayConnectivity,
244
- FinalizeGatewayInstall: completeInstall,
245
- ConfigFiles: Object.values(ConfigFiles),
246
- AgentNameMap: {
247
- [_types.AgentTypes.ca]: _types.AgentNames.TRACEABLE_CA
248
- },
249
- GatewayDisplay: _types.GatewayTypes.TRACEABLE
250
- };
251
- const testables = exports.testables = {
252
- prompts,
253
- ConfigFiles,
254
- askEnvironments,
255
- gatewayConnectivity,
256
- createTraceableCredsSecret
257
- };