@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,294 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.askBundleType = exports.GitHubSaaSInstallMethods = 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)('engage: install: agents: saas');
21
- class DataplaneConfig {
22
- constructor(type) {
23
- _defineProperty(this, "type", void 0);
24
- this.type = type || "";
25
- }
26
- }
27
- class GitHubDataplaneConfig extends DataplaneConfig {
28
- constructor(name, ownerName, filter) {
29
- super("GitHub");
30
- _defineProperty(this, "name", void 0);
31
- _defineProperty(this, "ownerName", void 0);
32
- _defineProperty(this, "filter", void 0);
33
- this.name = name;
34
- this.ownerName = ownerName;
35
- this.filter = filter;
36
- }
37
- }
38
- class GitHubFilterConfig {
39
- constructor(paths, branch, pattern) {
40
- _defineProperty(this, "paths", void 0);
41
- _defineProperty(this, "branch", void 0);
42
- _defineProperty(this, "pattern", void 0);
43
- this.paths = paths;
44
- this.branch = branch;
45
- this.pattern = pattern;
46
- }
47
- }
48
- class SaasAgentValues {
49
- constructor() {
50
- _defineProperty(this, "frequencyDA", void 0);
51
- _defineProperty(this, "queueDA", void 0);
52
- _defineProperty(this, "frequencyTA", void 0);
53
- _defineProperty(this, "dataplaneConfig", void 0);
54
- _defineProperty(this, "centralConfig", void 0);
55
- _defineProperty(this, "repositoryOwner", void 0);
56
- _defineProperty(this, "repositoryName", void 0);
57
- _defineProperty(this, "repositoryBranch", void 0);
58
- _defineProperty(this, "filePaths", void 0);
59
- _defineProperty(this, "filePatterns", void 0);
60
- this.frequencyDA = '';
61
- this.queueDA = false;
62
- this.frequencyTA = '';
63
- this.dataplaneConfig = new DataplaneConfig();
64
- this.centralConfig = new _types.CentralAgentConfig();
65
- this.repositoryOwner = '';
66
- this.repositoryName = '';
67
- this.repositoryBranch = '';
68
- this.filePaths = [];
69
- this.filePatterns = [];
70
- }
71
- }
72
- class SaasGitHubAgentValues extends SaasAgentValues {
73
- constructor() {
74
- super();
75
- _defineProperty(this, "accessToken", void 0);
76
- this.accessToken = '';
77
- }
78
- getAccessData() {
79
- let data = JSON.stringify({
80
- accessToken: this.accessToken
81
- });
82
- return data;
83
- }
84
- }
85
-
86
- // ConfigFiles - all the config file that are used in the setup
87
- const ConfigFiles = {};
88
-
89
- // GitHub SaaSPrompts - all GitHub Saas prompts to the user for input
90
- const SaasPrompts = {
91
- ACCESS_TOKEN: 'Enter the GitHub Access Token the agent will use',
92
- REPOSITORY_OWNER: 'Enter the GitHub Repository Owner the agent will use',
93
- REPOSITORY_NAME: 'Enter the Repository Name the agent will use',
94
- REPOSITORY_BRANCH: 'Enter the Repository Branch the agent will use',
95
- FILE_PATHS: 'Enter a File Path within the repository that the agent will use',
96
- FILE_PATTERNS: 'Enter a File Pattern that the agent will use (Optional)',
97
- DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
98
- QUEUE: 'Do you want to discover immediately after installation',
99
- ENTER_MORE_PATHS: 'Do you want to enter another file path ?',
100
- ENTER_MORE_PATTERNS: 'Do you want to enter another file pattern ?'
101
- };
102
- const askBundleType = async () => {
103
- //GitHub 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 askForGitHubCredentials = async hostedAgentValues => {
111
- log("gathering access details for GitHub");
112
- hostedAgentValues.accessToken = await (0, _basicPrompts.askInput)({
113
- msg: SaasPrompts.ACCESS_TOKEN,
114
- defaultValue: hostedAgentValues.accessToken !== '' ? hostedAgentValues.accessToken : undefined,
115
- validate: (0, _basicPrompts.validateRegex)(helpers.GitHubRegexPatterns.gitHubAccessTokenRegex, helpers.invalidValueExampleErrMsg('AccessToken', 'ghp_testTokentestTokentestTokentestToken'))
116
- });
117
- return hostedAgentValues;
118
- };
119
- const validateFrequency = () => input => {
120
- let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
121
- if (typeof val === "string") {
122
- return val;
123
- }
124
- let r = input.toString().match(/^(\d*)m/);
125
- if (r) {
126
- // only minutes
127
- let mins = r[1];
128
- if (parseInt(mins, 10) < 30) {
129
- return "Minimum frequency is 30m";
130
- }
131
- }
132
- return true;
133
- };
134
-
135
- // @ts-ignore
136
- const gatewayConnectivity = async installConfig => {
137
- console.log('\nCONNECTION TO GitHub API GATEWAY:');
138
- console.log(_chalk.default.gray("The Discovery Agent needs to connect to the GitHub API Gateway to discover API's for publishing to Amplify Engage"));
139
-
140
- // DeploymentType
141
- let hostedAgentValues = new SaasAgentValues();
142
- if (installConfig.gatewayType === _types.SaaSGatewayTypes.GITHUB) {
143
- // GitHub connection details
144
- hostedAgentValues = new SaasGitHubAgentValues();
145
- hostedAgentValues = await askForGitHubCredentials(hostedAgentValues);
146
- }
147
-
148
- // Ask to queue discovery now
149
- log("getting the frequency and if the agent should run now");
150
- 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."));
151
- hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
152
- msg: SaasPrompts.DA_FREQUENCY,
153
- validate: validateFrequency(),
154
- allowEmptyInput: true
155
- });
156
- hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
157
- msg: SaasPrompts.QUEUE,
158
- default: _types.YesNo.No,
159
- choices: _types.YesNoChoices
160
- })) === _types.YesNo.Yes;
161
-
162
- // get repository owner
163
- hostedAgentValues.repositoryOwner = await (0, _basicPrompts.askInput)({
164
- msg: SaasPrompts.REPOSITORY_OWNER,
165
- defaultValue: hostedAgentValues.repositoryOwner !== '' ? hostedAgentValues.repositoryOwner : undefined,
166
- validate: (0, _basicPrompts.validateRegex)(helpers.GitHubRegexPatterns.gitHubRepositoryOwnerRegex, helpers.invalidValueExampleErrMsg('Repository Owner', 'axway-github-owner'))
167
- });
168
-
169
- // get repository name
170
- hostedAgentValues.repositoryName = await (0, _basicPrompts.askInput)({
171
- msg: SaasPrompts.REPOSITORY_NAME,
172
- defaultValue: hostedAgentValues.repositoryName !== '' ? hostedAgentValues.repositoryName : undefined,
173
- validate: (0, _basicPrompts.validateRegex)(helpers.GitHubRegexPatterns.gitHubRepositoryNameRegex, helpers.invalidValueExampleErrMsg('Repository Name', 'axway-github-repo-name'))
174
- });
175
-
176
- // get repository branch
177
- hostedAgentValues.repositoryBranch = await (0, _basicPrompts.askInput)({
178
- msg: SaasPrompts.REPOSITORY_BRANCH,
179
- defaultValue: hostedAgentValues.repositoryBranch !== '' ? hostedAgentValues.repositoryBranch : undefined
180
- });
181
-
182
- // get File Paths
183
-
184
- let askFilePaths = true;
185
- console.log(_chalk.default.gray("An array of paths within the repository that the agent will gather files for looking for specs"));
186
- while (askFilePaths) {
187
- const path = await (0, _basicPrompts.askInput)({
188
- msg: SaasPrompts.FILE_PATHS,
189
- allowEmptyInput: false,
190
- validate: (0, _basicPrompts.validateRegex)(helpers.GitHubRegexPatterns.gitHubFilePathRegex, helpers.invalidValueExampleErrMsg('File Path', '/apis'))
191
- });
192
- hostedAgentValues.filePaths.push(path);
193
- askFilePaths = (await (0, _basicPrompts.askList)({
194
- msg: SaasPrompts.ENTER_MORE_PATHS,
195
- default: _types.YesNo.No,
196
- choices: _types.YesNoChoices
197
- })) === _types.YesNo.Yes;
198
- }
199
-
200
- // get File Patterns
201
-
202
- let askFilePatterns = true;
203
- console.log(_chalk.default.gray("An array of regular expressions that a file name must match to be discovered"));
204
- while (askFilePatterns) {
205
- const pattern = await (0, _basicPrompts.askInput)({
206
- msg: SaasPrompts.FILE_PATTERNS,
207
- allowEmptyInput: true
208
- });
209
- if (pattern.trim() !== "") {
210
- hostedAgentValues.filePatterns.push(pattern);
211
- askFilePatterns = (await (0, _basicPrompts.askList)({
212
- msg: SaasPrompts.ENTER_MORE_PATTERNS,
213
- default: _types.YesNo.No,
214
- choices: _types.YesNoChoices
215
- })) === _types.YesNo.Yes;
216
- } else {
217
- askFilePatterns = false;
218
- }
219
- }
220
- return hostedAgentValues;
221
- };
222
- const generateOutput = async installConfig => {
223
- return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
224
- };
225
- const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
226
- var _dataplaneRes$securit, _dataplaneRes$securit2;
227
- // grab key from data plane resource
228
- let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
229
- let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
230
- if (key === "" || hash === "") {
231
- throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
232
- }
233
- console.log(hostedAgentValues.getAccessData());
234
- let encData = _crypto.default.publicEncrypt({
235
- key: key,
236
- padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
237
- oaepHash: hash
238
- }, Buffer.from(hostedAgentValues.getAccessData()));
239
- return encData.toString("base64");
240
- };
241
- const completeInstall = async (installConfig, apiServerClient, defsManager) => {
242
- /**
243
- * Create agent resources
244
- */
245
- console.log("\n");
246
- let gitHubAgentValues = installConfig.gatewayConfig;
247
-
248
- // create the environment, if necessary
249
- installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
250
- axwayManaged: installConfig.centralConfig.axwayManaged,
251
- production: installConfig.centralConfig.production
252
- }) : installConfig.centralConfig.ampcEnvInfo.name;
253
- if (installConfig.gatewayType === _types.SaaSGatewayTypes.GITHUB) {
254
- gitHubAgentValues.dataplaneConfig = new GitHubDataplaneConfig(gitHubAgentValues.repositoryName, gitHubAgentValues.repositoryOwner, new GitHubFilterConfig(gitHubAgentValues.filePaths, gitHubAgentValues.repositoryBranch, gitHubAgentValues.filePatterns));
255
- }
256
-
257
- // create the data plane resource
258
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], gitHubAgentValues.dataplaneConfig);
259
- // create data plane secret resource
260
- try {
261
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(gitHubAgentValues, dataplaneRes));
262
- } catch (error) {
263
- console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
264
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
265
- await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
266
- } else {
267
- await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
268
- }
269
- return;
270
- }
271
-
272
- // create discovery agent resource
273
- 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, gitHubAgentValues.frequencyDA, gitHubAgentValues.queueDA);
274
- console.log(await generateOutput(installConfig));
275
- };
276
- const GitHubSaaSInstallMethods = exports.GitHubSaaSInstallMethods = {
277
- GetBundleType: askBundleType,
278
- GetDeploymentType: askConfigType,
279
- AskGatewayQuestions: gatewayConnectivity,
280
- FinalizeGatewayInstall: completeInstall,
281
- ConfigFiles: [],
282
- AgentNameMap: {
283
- [_types.AgentTypes.da]: _types.AgentNames.GITHUB_DA
284
- },
285
- GatewayDisplay: _types.SaaSGatewayTypes.GITHUB
286
- };
287
-
288
- // These are the items that are not exported, but need to be for testing
289
- const testables = exports.testables = {
290
- SaasAgentValues,
291
- SaasGitHubAgentValues,
292
- SaasPrompts,
293
- ConfigFiles
294
- };
@@ -1,178 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.installPreprocess = exports.gitLabPrompts = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.GitLabInstallMethods = 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 _gitLabTemplates = require("./helpers/templates/gitLabTemplates");
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)('engage: install: agents: gitLab:');
20
- const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.GITLAB_DA}`;
21
-
22
- // ConfigFiles - all the config file that are used in the setup
23
- const ConfigFiles = exports.ConfigFiles = {
24
- DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`
25
- };
26
- const gitLabPrompts = exports.gitLabPrompts = {
27
- ACCESS_TOKEN: 'Enter the GitLab Access Token the agent will use',
28
- BASE_URL: 'Enter the GitLab base URL that the agent will use',
29
- REPOSITORY_ID: 'Enter the GitLab Repository ID the agent will use',
30
- REPOSITORY_BRANCH: 'Enter the Repository Branch the agent will use',
31
- PATHS: 'Enter a Path within the repository that the agent will use',
32
- FILTERS: 'Enter a filter that the agent will use (Optional)',
33
- DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
34
- QUEUE: 'Do you want to discover immediately after installation',
35
- ENTER_MORE_PATHS: 'Do you want to enter another path ?',
36
- ENTER_MORE_FILTERS: 'Do you want to enter another filter ?'
37
- };
38
- const askBundleType = async () => {
39
- return _types.BundleType.DISCOVERY;
40
- };
41
- exports.askBundleType = askBundleType;
42
- const askConfigType = async () => {
43
- return _types.AgentConfigTypes.DOCKERIZED;
44
- };
45
-
46
- // Questions for the gitLab configuration
47
- exports.askConfigType = askConfigType;
48
- const askForGitLabToken = async () => await (0, _basicPrompts.askInput)({
49
- msg: gitLabPrompts.ACCESS_TOKEN,
50
- validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabAccessTokenRegex, helpers.invalidValueExampleErrMsg('AccessToken', 'mockToken'))
51
- });
52
- const askForGitLabBaseURL = async () => await (0, _basicPrompts.askInput)({
53
- msg: gitLabPrompts.BASE_URL,
54
- validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabBaseURLRegex, helpers.invalidValueExampleErrMsg('BaseURL', 'https://www.testdomain.com'))
55
- });
56
- const askForGitLabRepositoryID = async () => await (0, _basicPrompts.askInput)({
57
- msg: gitLabPrompts.REPOSITORY_ID,
58
- validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitHubRepositoryIDRegex, helpers.invalidValueExampleErrMsg('RepositoryID', '12312'))
59
- });
60
- const askForGitLabRepositoryBranch = async () => await (0, _basicPrompts.askInput)({
61
- msg: gitLabPrompts.REPOSITORY_BRANCH
62
- });
63
- const askForGitLabPaths = async () => {
64
- let askPaths = true;
65
- let paths = [];
66
- console.log(_chalk.default.gray("An array of paths within the repository that the agent will gather files for looking for specs"));
67
- while (askPaths) {
68
- const path = await (0, _basicPrompts.askInput)({
69
- msg: gitLabPrompts.PATHS,
70
- allowEmptyInput: false,
71
- validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabPathRegex, helpers.invalidValueExampleErrMsg('File Path', '/apis'))
72
- });
73
- paths.push(path);
74
- askPaths = (await (0, _basicPrompts.askList)({
75
- msg: gitLabPrompts.ENTER_MORE_PATHS,
76
- default: _types.YesNo.No,
77
- choices: _types.YesNoChoices
78
- })) === _types.YesNo.Yes;
79
- }
80
- return paths;
81
- };
82
- const askForGitLabFilters = async () => {
83
- let askFilters = true;
84
- let filters = [];
85
- console.log(_chalk.default.gray("An array of regular expressions that a file name must match to be discovered"));
86
- while (askFilters) {
87
- const filter = await (0, _basicPrompts.askInput)({
88
- msg: gitLabPrompts.FILTERS,
89
- allowEmptyInput: true
90
- });
91
- if (filter.trim() != '') {
92
- filters.push(filter);
93
- askFilters = (await (0, _basicPrompts.askList)({
94
- msg: gitLabPrompts.ENTER_MORE_FILTERS,
95
- default: _types.YesNo.No,
96
- choices: _types.YesNoChoices
97
- })) === _types.YesNo.Yes;
98
- } else {
99
- askFilters = false;
100
- }
101
- }
102
- return filters;
103
- };
104
- const gatewayConnectivity = async installConfig => {
105
- let gitLabAgentValues = new _gitLabTemplates.GitLabAgentValues();
106
- if (installConfig.switches.isDockerInstall) {
107
- console.log('\nCONNECTION TO GitHub API GATEWAY:');
108
- console.log(_chalk.default.gray("The Discovery Agent needs to connect to the GitHub API Gateway to discover API's for publishing to Amplify Engage."));
109
- gitLabAgentValues.token = await askForGitLabToken();
110
- gitLabAgentValues.baseURL = await askForGitLabBaseURL();
111
- gitLabAgentValues.repositoryID = await askForGitLabRepositoryID();
112
- gitLabAgentValues.repositoryBranch = await askForGitLabRepositoryBranch();
113
- gitLabAgentValues.paths = await askForGitLabPaths();
114
- gitLabAgentValues.filters = await askForGitLabFilters();
115
- }
116
- return gitLabAgentValues;
117
- };
118
- exports.gatewayConnectivity = gatewayConnectivity;
119
- const dockerSuccessMsg = installConfig => {
120
- let dockerInfo;
121
- const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
122
- const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
123
- const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
124
- const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
125
- if (installConfig.switches.isDaEnabled) {
126
- dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
127
- }
128
- console.log(_chalk.default.whiteBright(dockerInfo), '\n');
129
- if (installConfig.switches.isDaEnabled) {
130
- const daImageVersion = `${daImage}:${installConfig.daVersion}`;
131
- console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
132
- console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
133
- console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
134
- console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
135
- console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`));
136
- }
137
- };
138
- const generateSuccessHelpMsg = installConfig => {
139
- const configType = installConfig.deploymentType;
140
- if (configType === _types.AgentConfigTypes.DOCKERIZED) {
141
- dockerSuccessMsg(installConfig);
142
- }
143
- };
144
- const installPreprocess = async installConfig => {
145
- return installConfig;
146
- };
147
- exports.installPreprocess = installPreprocess;
148
- const completeInstall = async installConfig => {
149
- /**
150
- * Create agent resources
151
- */
152
- const gitLabAgentValues = installConfig.gatewayConfig;
153
-
154
- // Add final settings to gitLabAgentValues
155
- gitLabAgentValues.centralConfig = installConfig.centralConfig;
156
- gitLabAgentValues.daVersion = installConfig.daVersion;
157
- if (installConfig.switches.isDockerInstall) {
158
- if (installConfig.switches.isDaEnabled) {
159
- (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, gitLabAgentValues, helpers.gitLabDAEnvVarTemplate);
160
- }
161
- }
162
- console.log('Configuration file(s) have been successfully created.\n');
163
- generateSuccessHelpMsg(installConfig);
164
- };
165
- exports.completeInstall = completeInstall;
166
- const GitLabInstallMethods = exports.GitLabInstallMethods = {
167
- GetBundleType: askBundleType,
168
- GetDeploymentType: askConfigType,
169
- AskGatewayQuestions: gatewayConnectivity,
170
- InstallPreprocess: installPreprocess,
171
- FinalizeGatewayInstall: completeInstall,
172
- ConfigFiles: Object.values(ConfigFiles),
173
- GatewayDisplay: _types.GatewayTypes.GITLAB
174
- };
175
- const testables = exports.testables = {
176
- gitLabPrompts,
177
- ConfigFiles
178
- };
@@ -1,147 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.GraylogInstallMethods = 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 _graylogTemplates = require("./helpers/templates/graylogTemplates");
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)('engage: install: agents: graylog');
22
- const amplifyAgentsNs = exports.amplifyAgentsNs = 'amplify-agents';
23
-
24
- // ConfigFiles - all the config file that are used in the setup
25
- const ConfigFiles = exports.ConfigFiles = {
26
- helmOverride: 'agent-overrides.yaml'
27
- };
28
-
29
- // GraylogPrompts - prompts for user inputs
30
- const prompts = {
31
- agentNamespace: 'Enter the namespace to use for the Amplify Graylog Agents',
32
- enterUrl: 'Enter the Graylog base URL that the agent will use',
33
- enterUsername: 'Enter the Graylog user name',
34
- enterPassword: 'Enter the password for Graylog user',
35
- enterBasePathSegmentLen: 'Enter the base path segment length that agent will use for lookup'
36
- };
37
- const askBundleType = async () => {
38
- return _types.BundleType.TRACEABILITY;
39
- };
40
- exports.askBundleType = askBundleType;
41
- const askConfigType = async () => {
42
- return _types.AgentConfigTypes.HELM;
43
- };
44
-
45
- //
46
- // Questions for the configuration of Graylog agent
47
- //
48
- exports.askConfigType = askConfigType;
49
- const askURL = async () => await (0, _basicPrompts.askInput)({
50
- msg: prompts.enterUrl,
51
- allowEmptyInput: false,
52
- validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabBaseURLRegex, helpers.invalidValueExampleErrMsg('BaseURL', 'https://www.testdomain.com'))
53
- });
54
- const askUsername = async () => await (0, _basicPrompts.askInput)({
55
- msg: prompts.enterUsername,
56
- allowEmptyInput: false
57
- });
58
- const askPassword = async () => await (0, _basicPrompts.askInput)({
59
- msg: prompts.enterPassword
60
- });
61
- const askBasePathSegmentLen = async () => await (0, _basicPrompts.askInput)({
62
- msg: prompts.enterBasePathSegmentLen,
63
- type: 'number',
64
- defaultValue: 2
65
- });
66
- const gatewayConnectivity = async _installConfig => {
67
- console.log(_chalk.default.gray(`The Amplify Graylog Agent needs to be deployed to your Kubernetes cluster to discover APIs for publishing to Amplify Engage.`));
68
- const {
69
- error
70
- } = await _Kubectl.kubectl.isInstalled();
71
- if (error) {
72
- throw new Error(`Kubectl is required to fill out the following prompts. It appears to be missing or misconfigured.\n${error}`);
73
- }
74
- const graylogAgentValues = new _graylogTemplates.GraylogAgentValues();
75
- graylogAgentValues.namespace = await (0, _inputs.askNamespace)(prompts.agentNamespace, amplifyAgentsNs);
76
- graylogAgentValues.url = await askURL();
77
- graylogAgentValues.userName = await askUsername();
78
- graylogAgentValues.password = await askPassword();
79
- graylogAgentValues.basePathSegmentLen = await askBasePathSegmentLen();
80
- return graylogAgentValues;
81
- };
82
- exports.gatewayConnectivity = gatewayConnectivity;
83
- const generateSuccessHelpMsg = namespace => {
84
- console.log(`Graylog Agent override file has been placed at ${process.cwd()}/${ConfigFiles.helmOverride}`);
85
- helpers.helmImageSecretInfo(namespace);
86
- let agentHelmInfo = new Set();
87
- agentHelmInfo.add({
88
- helmReleaseName: 'graylog-agent',
89
- helmChartName: 'axway/graylog-agent',
90
- overrideFileName: ConfigFiles.helmOverride,
91
- imageSecretOverrides: `--set image.pullSecret=<image-pull-secret-name>`
92
- });
93
- helpers.helmInstallInfo('Graylog', namespace, agentHelmInfo);
94
- console.log('Configuration file(s) have been successfully created.\n');
95
- console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.GRAYLOG}`));
96
- };
97
- const completeInstall = async installConfig => {
98
- // Add final settings to graylogAgentValues
99
- const graylogAgentValues = installConfig.gatewayConfig;
100
- if (graylogAgentValues.namespace.isNew) {
101
- await helpers.createNamespace(graylogAgentValues.namespace.name);
102
- }
103
- graylogAgentValues.centralConfig = installConfig.centralConfig;
104
- graylogAgentValues.graylogSecret = helpers.amplifyAgentsCredsSecret;
105
- graylogAgentValues.agentKeysSecret = helpers.amplifyAgentsKeysSecret;
106
- // read file content
107
- await helpers.createSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, async () => {
108
- if (installConfig.centralConfig.ampcDosaInfo.isNew) {
109
- 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.`));
110
- }
111
- await helpers.createAmplifyAgentKeysSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, 'publicKey', graylogAgentValues.centralConfig.dosaAccount.publicKey, 'privateKey', graylogAgentValues.centralConfig.dosaAccount.privateKey);
112
- });
113
- await helpers.createSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, async () => {
114
- await createGraylogCredsSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, graylogAgentValues.userName, graylogAgentValues.password);
115
- });
116
- graylogAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
117
- console.log('Generating the configuration file(s)...');
118
- (0, _utils.writeTemplates)(ConfigFiles.helmOverride, graylogAgentValues, helpers.graylogHelmOverrideTemplate);
119
- generateSuccessHelpMsg(graylogAgentValues.namespace.name);
120
- };
121
- exports.completeInstall = completeInstall;
122
- const createGraylogCredsSecret = async (namespace, secretName, user, password) => {
123
- const {
124
- error
125
- } = await _Kubectl.kubectl.create('secret', `-n ${namespace} generic ${secretName} \
126
- --from-literal=username=${user} \
127
- --from-literal=password=${password}`);
128
- if (error) {
129
- throw Error(error);
130
- }
131
- console.log(`Created ${secretName} in the ${namespace} namespace.`);
132
- };
133
- const GraylogInstallMethods = exports.GraylogInstallMethods = {
134
- GetBundleType: askBundleType,
135
- GetDeploymentType: askConfigType,
136
- AskGatewayQuestions: gatewayConnectivity,
137
- FinalizeGatewayInstall: completeInstall,
138
- ConfigFiles: Object.values(ConfigFiles),
139
- AgentNameMap: {
140
- [_types.AgentTypes.ca]: _types.AgentNames.GRAYLOG_CA
141
- },
142
- GatewayDisplay: _types.GatewayTypes.GRAYLOG
143
- };
144
- const testables = exports.testables = {
145
- prompts,
146
- ConfigFiles
147
- };