@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,275 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.askTraceableRegion = exports.askBundleType = exports.TraceableSaaSInstallMethods = 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 _crypto = _interopRequireDefault(require("crypto"));
12
- var helpers = _interopRequireWildcard(require("./helpers"));
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)('engage: install: agents: Traceable');
21
- class DataplaneConfig {
22
- constructor(type) {
23
- _defineProperty(this, "type", void 0);
24
- this.type = type || '';
25
- }
26
- }
27
- class TraceableDataplaneConfig extends DataplaneConfig {
28
- constructor(region, environments) {
29
- super("Traceable");
30
- _defineProperty(this, "region", void 0);
31
- _defineProperty(this, "environments", void 0);
32
- this.region = region;
33
- this.environments = environments;
34
- }
35
- }
36
- class TraceableEnvironments {
37
- constructor(traceable, environment) {
38
- _defineProperty(this, "traceable", void 0);
39
- _defineProperty(this, "environment", void 0);
40
- this.traceable = traceable;
41
- this.environment = environment;
42
- }
43
- }
44
- class SaasAgentValues {
45
- constructor() {
46
- _defineProperty(this, "dataplaneConfig", void 0);
47
- _defineProperty(this, "centralConfig", void 0);
48
- this.dataplaneConfig = new DataplaneConfig();
49
- this.centralConfig = new _types.CentralAgentConfig();
50
- }
51
- getAccessData() {
52
- return '';
53
- }
54
- }
55
- class SaasTraceableAgentValues extends SaasAgentValues {
56
- constructor() {
57
- super();
58
- _defineProperty(this, "traceableToken", void 0);
59
- _defineProperty(this, "traceableRegion", void 0);
60
- _defineProperty(this, "environments", void 0);
61
- _defineProperty(this, "centralEnvironments", void 0);
62
- this.traceableToken = '';
63
- this.traceableRegion = _types.TraceableRegionType.US;
64
- this.environments = [];
65
- this.centralEnvironments = [];
66
- }
67
- getAccessData() {
68
- let data = JSON.stringify({
69
- token: this.traceableToken
70
- });
71
- return data;
72
- }
73
- }
74
-
75
- // ConfigFiles - all the config file that are used in the setup
76
- const ConfigFiles = {};
77
-
78
- // TraceableSaaSPrompts - all Traceable Saas prompts to the user for input
79
- const SaasPrompts = {
80
- configTypeMsg: 'Select the mode of installation',
81
- agentNamespace: 'Enter the namespace to use for the Amplify Traceable Agents',
82
- enterToken: 'Enter the token that the agent will use',
83
- enterRegion: 'Enter the region that the agent will use',
84
- enterEnvironments: 'Enter a Traceable environment',
85
- enterMoreEnvironments: 'Do you want to enter another mapping?',
86
- selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Traceable environment',
87
- environmentsDescription: 'Configure a mapping of Traceable environment to Engage environment that the agent will use'
88
- };
89
- const askBundleType = async () => {
90
- return _types.BundleType.TRACEABILITY;
91
- };
92
- exports.askBundleType = askBundleType;
93
- const askConfigType = async () => {
94
- return _types.AgentConfigTypes.HOSTED;
95
- };
96
- const askEnvironments = async (centralEnvs, hostedAgentValues, excludeEnvironment) => {
97
- // Filter out the already-selected agent installation environment
98
- if (excludeEnvironment) {
99
- centralEnvs = centralEnvs.filter(env => env.name !== excludeEnvironment);
100
- }
101
- let askEnvs = true;
102
- let envs = [];
103
- let mappedCentralEnvs = [];
104
- console.log(_chalk.default.gray(SaasPrompts.environmentsDescription));
105
- while (askEnvs) {
106
- const env = await (0, _basicPrompts.askInput)({
107
- msg: SaasPrompts.enterEnvironments,
108
- allowEmptyInput: true
109
- });
110
- if (envs.length === 0 && (!env || env.toString().trim() === "")) {
111
- break;
112
- }
113
- if (env && env.toString().trim() !== "") {
114
- envs.push(env);
115
- }
116
- const centralMappingEnv = await (0, _basicPrompts.askList)({
117
- msg: SaasPrompts.selectCentralMappingEnvironment,
118
- choices: centralEnvs.map(e => e.name)
119
- });
120
- if (centralMappingEnv && centralMappingEnv.toString().trim() !== "") {
121
- mappedCentralEnvs.push(centralMappingEnv);
122
- }
123
- centralEnvs = centralEnvs.filter(env => env.name !== centralMappingEnv);
124
-
125
- // Only ask if they want to continue if there are still environments available to map
126
- if (centralEnvs.length > 0) {
127
- askEnvs = (await (0, _basicPrompts.askList)({
128
- msg: SaasPrompts.enterMoreEnvironments,
129
- default: _types.YesNo.No,
130
- choices: _types.YesNoChoices
131
- })) === _types.YesNo.Yes;
132
- } else {
133
- askEnvs = false;
134
- }
135
- }
136
- hostedAgentValues.environments = envs;
137
- hostedAgentValues.centralEnvironments = mappedCentralEnvs;
138
- };
139
- const validateFrequency = () => input => {
140
- let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
141
- if (typeof val === "string") {
142
- return val;
143
- }
144
- let r = input.toString().match(/^(\d*)m/);
145
- if (r) {
146
- // only minutes
147
- let mins = r[1];
148
- if (parseInt(mins, 10) < 30) {
149
- return "Minimum frequency is 30m";
150
- }
151
- }
152
- return true;
153
- };
154
-
155
- //
156
- // Questions for the configuration of Traceable agent
157
- //
158
- const askToken = async () => await (0, _basicPrompts.askInput)({
159
- msg: SaasPrompts.enterToken,
160
- allowEmptyInput: false
161
- });
162
- const askTraceableRegion = async () => {
163
- return await (0, _basicPrompts.askList)({
164
- msg: SaasPrompts.enterRegion,
165
- choices: Object.entries(_types.TraceableRegionType).reduce((accumulator, curr) => {
166
- return accumulator.concat({
167
- name: curr[0],
168
- value: curr[1]
169
- });
170
- }, []),
171
- default: _types.TraceableRegionType.US
172
- });
173
- };
174
-
175
- // @ts-ignore
176
- exports.askTraceableRegion = askTraceableRegion;
177
- const gatewayConnectivity = async installConfig => {
178
- console.log('\nCONNECTION TO TRACEABLE API GATEWAY:');
179
- // DeploymentType
180
- let hostedAgentValues = new SaasTraceableAgentValues();
181
- if (installConfig.gatewayType === _types.SaaSGatewayTypes.TRACEABLE) {
182
- var _installConfig$centra;
183
- log('gathering access details for traceable');
184
-
185
- // Traceable connection details
186
- hostedAgentValues = new SaasTraceableAgentValues();
187
- hostedAgentValues.traceableToken = await askToken();
188
- hostedAgentValues.traceableRegion = await askTraceableRegion();
189
- const centralEnvs = await helpers.getCentralEnvironments(installConfig.centralConfig.apiServerClient, installConfig.centralConfig.definitionManager);
190
- // Pass the already-selected agent installation environment to exclude it from mapping choices
191
- const agentInstallEnv = (_installConfig$centra = installConfig.centralConfig.ampcEnvInfo) === null || _installConfig$centra === void 0 ? void 0 : _installConfig$centra.name;
192
- await askEnvironments(centralEnvs, hostedAgentValues, agentInstallEnv);
193
- }
194
- return hostedAgentValues;
195
- };
196
- const generateOutput = async installConfig => {
197
- return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
198
- };
199
- const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
200
- var _dataplaneRes$securit, _dataplaneRes$securit2;
201
- // grab key from data plane resource
202
- let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
203
- let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
204
- if (key === "" || hash === "") {
205
- throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
206
- }
207
- const accessData = hostedAgentValues.getAccessData();
208
- let encData = _crypto.default.publicEncrypt({
209
- key: key,
210
- padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
211
- oaepHash: hash
212
- }, Buffer.from(accessData));
213
- return encData.toString("base64");
214
- };
215
- const completeInstall = async (installConfig, apiServerClient, defsManager) => {
216
- /**
217
- * Create agent resources
218
- */
219
- console.log("\n");
220
- let traceableAgentValues = installConfig.gatewayConfig;
221
-
222
- // create the environment, if necessary
223
- installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
224
- axwayManaged: installConfig.centralConfig.axwayManaged,
225
- production: installConfig.centralConfig.production
226
- }) : installConfig.centralConfig.ampcEnvInfo.name;
227
- if (installConfig.gatewayType === _types.GatewayTypes.TRACEABLE) {
228
- const traceableEnvObjs = (traceableAgentValues.environments || []).map((env, idx) => new TraceableEnvironments(env, traceableAgentValues.centralEnvironments[idx]));
229
- traceableAgentValues.dataplaneConfig = new TraceableDataplaneConfig(traceableAgentValues.traceableRegion, traceableEnvObjs);
230
- }
231
-
232
- // create the data plane resource
233
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], traceableAgentValues.dataplaneConfig);
234
- // create data plane secret resource
235
- try {
236
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(traceableAgentValues, dataplaneRes));
237
- } catch (error) {
238
- log(error);
239
- console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
240
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
241
- await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
242
- } else {
243
- await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
244
- }
245
- return;
246
- }
247
-
248
- // create compliance agent resource
249
- installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ca, _types.AgentTypes.ca, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Compliance Agent", dataplaneRes.name);
250
- console.log(await generateOutput(installConfig));
251
- };
252
- const TraceableSaaSInstallMethods = exports.TraceableSaaSInstallMethods = {
253
- GetBundleType: askBundleType,
254
- GetDeploymentType: askConfigType,
255
- AskGatewayQuestions: gatewayConnectivity,
256
- FinalizeGatewayInstall: completeInstall,
257
- ConfigFiles: [],
258
- AgentNameMap: {
259
- [_types.AgentTypes.ca]: _types.AgentNames.TRACEABLE_CA
260
- },
261
- GatewayDisplay: _types.GatewayTypes.TRACEABLE
262
- };
263
-
264
- // These are the items that are not exported, but need to be for testing
265
- const testables = exports.testables = {
266
- SaasAgentValues,
267
- SaasTraceableAgentValues,
268
- SaasPrompts,
269
- ConfigFiles,
270
- createEncryptedAccessData,
271
- // <-- already exported
272
- validateFrequency,
273
- // <-- add this line for test access
274
- askEnvironments // <-- add this for testing the new logic
275
- };
@@ -1,163 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.gatewayConnectivity = exports.defaultLogFiles = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.WSO2InstallMethods = exports.ConfigFiles = 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 _utils = require("../../common/utils");
12
- var helpers = _interopRequireWildcard(require("./helpers"));
13
- var _wso2Templates = require("./helpers/templates/wso2Templates");
14
- 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); }
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- // @ts-ignore
17
- const {
18
- log
19
- } = (0, _snooplogg.default)('central: install: agents: WSO2');
20
- const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.WSO2_DA}`;
21
- const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.WSO2_TA}`;
22
- const defaultLogFiles = exports.defaultLogFiles = '/group-*_instance-*.log';
23
-
24
- // ConfigFiles - all the config file that are used in the setup
25
- const ConfigFiles = exports.ConfigFiles = {
26
- DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
27
- TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`,
28
- WSO2DABinaryFile: 'discovery_agent',
29
- WSO2DAYaml: 'discovery_agent.yml',
30
- WSO2TABinaryFile: 'traceability_agent',
31
- WSO2TAYaml: 'traceability_agent.yml'
32
- };
33
-
34
- // WSO2Prompts - prompts for user inputs
35
- const WSO2Prompts = {
36
- configTypeMsg: 'Select the mode of installation',
37
- enterWSO2BaseURL: 'Enter the WSO2 baseURL',
38
- enterWSO2ClientID: 'Enter the WSO2 ClientID',
39
- enterWSO2ClientSecret: 'Enter the WSO2 ClientSecret'
40
- };
41
- const askBundleType = async () => {
42
- return await (0, _basicPrompts.askList)({
43
- msg: helpers.agentMessages.selectAgentType,
44
- choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY, _types.BundleType.TRACEABILITY]
45
- });
46
- };
47
- exports.askBundleType = askBundleType;
48
- const askConfigType = async () => {
49
- return _types.AgentConfigTypes.DOCKERIZED;
50
- };
51
-
52
- //
53
- // Questions for the configuration of WSO2 agents
54
- //
55
- exports.askConfigType = askConfigType;
56
- const askWSO2BaseURL = async () => await (0, _basicPrompts.askInput)({
57
- msg: WSO2Prompts.enterWSO2BaseURL,
58
- allowEmptyInput: false,
59
- validate: (0, _basicPrompts.validateRegex)(helpers.WSO2RegexPatterns.wso2BaseURLRegex, helpers.invalidValueExampleErrMsg('WSO2_BASEURL', 'https://www.wso2domain.com'))
60
- });
61
- const askWSO2ClientID = async () => await (0, _basicPrompts.askInput)({
62
- msg: WSO2Prompts.enterWSO2ClientID
63
- });
64
- const askWSO2ClientSecret = async () => await (0, _basicPrompts.askInput)({
65
- msg: WSO2Prompts.enterWSO2ClientSecret
66
- });
67
- const gatewayConnectivity = async installConfig => {
68
- const agentValues = new _wso2Templates.WSO2AgentValues();
69
- console.log('\nCONNECTION TO WSO2:');
70
- console.log(_chalk.default.gray(`The discovery agent needs to connect to the WSO2 API Manager to discover API's for publishing to Amplify.\nThe traceability agent will serve as the trace logging service that will receive WSO2 tracing payloads. These will be forwarded to the Business Insights. There are no specific WSO2 Traceability agent variables.\n`));
71
- if (installConfig.switches.isDaEnabled) {
72
- console.log(_chalk.default.gray(`\nDiscovery Agent Configuration\n`));
73
- await askDiscoveryPrompts(agentValues);
74
- }
75
- return agentValues;
76
- };
77
- exports.gatewayConnectivity = gatewayConnectivity;
78
- const generateSuccessHelpMsg = installConfig => {
79
- if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
80
- 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.'));
81
- }
82
- dockerSuccessMsg(installConfig);
83
- console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.WSO2}`));
84
- };
85
- const dockerSuccessMsg = installConfig => {
86
- let dockerInfo;
87
- const runDaLinuxMsg = `docker run --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
88
- const runDaWinMsg = `docker run --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
89
- const runTaLinuxMsg = `docker run --env-file ${helpers.pwd}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
90
- const runTaWinMsg = `docker run --env-file ${helpers.pwdWin}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
91
- const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
92
- const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
93
- const startTaLinuxMsg = `\nStart the Traceability Agent on a Linux based machine`;
94
- const startTaWinMsg = `\nStart the Traceability Agent on a Windows machine`;
95
- if (installConfig.switches.isDaEnabled && installConfig.switches.isTaEnabled) {
96
- dockerInfo = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${helpers.configFiles.DA_ENV_VARS} & ${helpers.configFiles.TA_ENV_VARS}):`;
97
- } else if (installConfig.switches.isDaEnabled) {
98
- dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
99
- } else {
100
- dockerInfo = `To utilize the traceability agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.TA_ENV_VARS}):`;
101
- }
102
- console.log(_chalk.default.whiteBright(dockerInfo), '\n');
103
- if (installConfig.switches.isDaEnabled) {
104
- const daImageVersion = `${daImage}:${installConfig.daVersion}`;
105
- console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
106
- console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
107
- console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
108
- console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
109
- console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`), '\n');
110
- }
111
- if (installConfig.switches.isTaEnabled) {
112
- const taImageVersion = `${taImage}:${installConfig.taVersion}`;
113
- console.log(_chalk.default.white('Pull the latest image of the Traceability Agent:'));
114
- console.log(_chalk.default.cyan(`docker pull ${taImageVersion}`));
115
- console.log(_chalk.default.white(_utils.isWindows ? startTaWinMsg : startTaLinuxMsg));
116
- console.log(_chalk.default.cyan(_utils.isWindows ? runTaWinMsg : runTaLinuxMsg));
117
- console.log('\t', _chalk.default.cyan(`-v /data -p 8888:8888 ${helpers.eolChar}`));
118
- console.log('\t', _chalk.default.cyan(`${taImageVersion}`), '\n');
119
- console.log(_chalk.default.white('Configure WSO2 to connect to localhost:8888.'));
120
- }
121
- };
122
- async function askDiscoveryPrompts(agentValues) {
123
- agentValues.wso2BaseURL = await askWSO2BaseURL();
124
- agentValues.wso2ClientID = await askWSO2ClientID();
125
- agentValues.wso2ClientSecret = await askWSO2ClientSecret();
126
- }
127
- const completeInstall = async installConfig => {
128
- /**
129
- * Create agent resources
130
- */
131
- const agentValues = installConfig.gatewayConfig;
132
-
133
- // Add final settings to WSO2 agentValues
134
- agentValues.centralConfig = installConfig.centralConfig;
135
- agentValues.traceabilityConfig = installConfig.traceabilityConfig;
136
- console.log('Generating the configuration file(s)...');
137
- if (installConfig.switches.isDaEnabled) {
138
- (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, agentValues, _wso2Templates.wso2DAEnvVarTemplate);
139
- }
140
- if (installConfig.switches.isTaEnabled) {
141
- (0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, agentValues, _wso2Templates.wso2TAEnvVarTemplate);
142
- }
143
- console.log('Configuration file(s) have been successfully created.\n');
144
- generateSuccessHelpMsg(installConfig);
145
- };
146
- exports.completeInstall = completeInstall;
147
- const WSO2InstallMethods = exports.WSO2InstallMethods = {
148
- GetBundleType: askBundleType,
149
- GetDeploymentType: askConfigType,
150
- AskGatewayQuestions: gatewayConnectivity,
151
- FinalizeGatewayInstall: completeInstall,
152
- ConfigFiles: Object.values(ConfigFiles),
153
- AgentNameMap: {
154
- [_types.AgentTypes.da]: _types.AgentNames.WSO2_DA,
155
- [_types.AgentTypes.ta]: _types.AgentNames.WSO2_TA
156
- },
157
- GatewayDisplay: _types.GatewayTypes.WSO2
158
- };
159
- const testables = exports.testables = {
160
- WSO2Prompts,
161
- ConfigFiles,
162
- defaultLogFiles
163
- };