@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,167 +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.ConfigFiles = exports.BackstageInstallMethods = 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 _backstageTemplates = require("./helpers/templates/backstageTemplates");
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: backstage');
20
- const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.BACKSTAGE_DA}`;
21
- const defaultLogFiles = exports.defaultLogFiles = '/group-*_instance-*.log';
22
-
23
- // ConfigFiles - all the config file that are used in the setup
24
- const ConfigFiles = exports.ConfigFiles = {
25
- DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
26
- BackstageDABinaryFile: 'discovery_agent',
27
- BackstageDAYaml: 'discovery_agent.yml'
28
- };
29
- const BackstagePrompts = {
30
- enterUrlHost: 'Enter the host of the URL for connecting to Backstage',
31
- selectUrlScheme: 'Select the scheme of the URL for connecting to Backstage',
32
- enterBackendPort: '(Optional) Enter the backend port of the URL for connecting to Backstage',
33
- enterUrlPath: '(Optional) Enter the path of the URL for connecting to Backstage',
34
- selectAuthMode: 'Select the authentication type for connecting to Backstage',
35
- enterStaticTokenValue: 'Enter the static token value',
36
- enterJwksClientID: 'Enter the ClientID for the JWKS Auth Flow',
37
- enterJwksClientSecret: 'Enter the ClientSecret for the JWKS Auth Flow',
38
- enterJwksTokenURL: 'Enter TokenURL for the JWKS Auth Flow'
39
- };
40
- const askBundleType = async () => {
41
- // Backstage agent has only DA
42
- return _types.BundleType.DISCOVERY;
43
- };
44
- exports.askBundleType = askBundleType;
45
- const askConfigType = async () => {
46
- return _types.AgentConfigTypes.DOCKERIZED;
47
- };
48
-
49
- //
50
- // Questions for the configuration of Backstage agent
51
- //
52
- exports.askConfigType = askConfigType;
53
- const askBackstageUrlHost = async () => await (0, _basicPrompts.askInput)({
54
- msg: BackstagePrompts.enterUrlHost
55
- });
56
- const askBackstageUrlScheme = async () => await (0, _basicPrompts.askList)({
57
- msg: BackstagePrompts.selectUrlScheme,
58
- choices: [_backstageTemplates.UrlScheme.HTTP, _backstageTemplates.UrlScheme.HTTPS]
59
- });
60
- const askBackstageUrlBackendPort = async () => await (0, _basicPrompts.askInput)({
61
- msg: BackstagePrompts.enterBackendPort,
62
- allowEmptyInput: true
63
- });
64
- const askBackstageUrlPath = async () => await (0, _basicPrompts.askInput)({
65
- msg: BackstagePrompts.enterUrlPath,
66
- allowEmptyInput: true
67
- });
68
- const askBackstageAuthMode = async () => await (0, _basicPrompts.askList)({
69
- msg: BackstagePrompts.selectAuthMode,
70
- choices: [{
71
- name: "No auth",
72
- value: _backstageTemplates.AuthMode.NoAuth
73
- }, _backstageTemplates.AuthMode.Guest, _backstageTemplates.AuthMode.StaticToken, _backstageTemplates.AuthMode.Jwks]
74
- });
75
- const askBackstageAuthStaticToken = async () => await (0, _basicPrompts.askInput)({
76
- msg: BackstagePrompts.enterStaticTokenValue
77
- });
78
- const askBaskstageAuthJwksClientID = async () => await (0, _basicPrompts.askInput)({
79
- msg: BackstagePrompts.enterJwksClientID
80
- });
81
- const askBaskstageAuthJwksClientSecret = async () => await (0, _basicPrompts.askInput)({
82
- msg: BackstagePrompts.enterJwksClientSecret
83
- });
84
- const askBaskstageAuthJwksTokenUrl = async () => await (0, _basicPrompts.askInput)({
85
- msg: BackstagePrompts.enterJwksTokenURL
86
- });
87
- const gatewayConnectivity = async () => {
88
- const backstageAgentValues = new _backstageTemplates.BackstageAgentValues();
89
- console.log('\nCONNECTION TO Backstage:');
90
- console.log(_chalk.default.gray(`The discovery agent needs to connect to Backstage to discover API's for publishing to Amplify.`));
91
- await askPrompts(backstageAgentValues);
92
- return backstageAgentValues;
93
- };
94
- exports.gatewayConnectivity = gatewayConnectivity;
95
- const generateSuccessHelpMsg = installConfig => {
96
- 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.'));
97
- dockerSuccessMsg(installConfig);
98
- console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.BACKSTAGE}`));
99
- };
100
- const dockerSuccessMsg = installConfig => {
101
- let dockerInfo;
102
- const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
103
- const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
104
- const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
105
- const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
106
- dockerInfo = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${helpers.configFiles.DA_ENV_VARS}:`;
107
- console.log(_chalk.default.whiteBright(dockerInfo), '\n');
108
- const daImageVersion = `${daImage}:${installConfig.daVersion}`;
109
- console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
110
- console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
111
- console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
112
- console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
113
- console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`), '\n');
114
- };
115
- async function askPrompts(values) {
116
- values.host = await askBackstageUrlHost();
117
- values.scheme = await askBackstageUrlScheme();
118
- values.backendPort = await askBackstageUrlBackendPort();
119
- values.urlPath = await askBackstageUrlPath();
120
- values.authMode = await askBackstageAuthMode();
121
- switch (values.authMode) {
122
- case _backstageTemplates.AuthMode.StaticToken:
123
- {
124
- values.staticTokenValue = await askBackstageAuthStaticToken();
125
- break;
126
- }
127
- case _backstageTemplates.AuthMode.Jwks:
128
- {
129
- values.jwksClientID = await askBaskstageAuthJwksClientID();
130
- values.jwksClientSecret = await askBaskstageAuthJwksClientSecret();
131
- values.jwksTokenURL = await askBaskstageAuthJwksTokenUrl();
132
- break;
133
- }
134
- }
135
- return values;
136
- }
137
- const completeInstall = async installConfig => {
138
- /**
139
- * Create agent resources
140
- */
141
- const backstageAgentValues = installConfig.gatewayConfig;
142
-
143
- // Add final settings
144
- backstageAgentValues.centralConfig = installConfig.centralConfig;
145
- console.log('Generating the configuration file(s)...');
146
- (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, backstageAgentValues, _backstageTemplates.backstageDAEnvVarTemplate);
147
- console.log('Configuration file(s) have been successfully created.\n');
148
- generateSuccessHelpMsg(installConfig);
149
- };
150
- exports.completeInstall = completeInstall;
151
- const BackstageInstallMethods = exports.BackstageInstallMethods = {
152
- GetBundleType: askBundleType,
153
- GetDeploymentType: askConfigType,
154
- AskGatewayQuestions: gatewayConnectivity,
155
- FinalizeGatewayInstall: completeInstall,
156
- ConfigFiles: Object.values(ConfigFiles),
157
- AgentNameMap: {
158
- [_types.AgentTypes.da]: _types.AgentNames.BACKSTAGE_DA,
159
- [_types.AgentTypes.ta]: _types.AgentNames.BACKSTAGE_DA
160
- },
161
- GatewayDisplay: _types.GatewayTypes.BACKSTAGE
162
- };
163
- const testables = exports.testables = {
164
- BackstagePrompts,
165
- ConfigFiles,
166
- defaultLogFiles
167
- };
@@ -1,409 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.prompts = exports.installPreprocess = exports.gatewayConnectivity = exports.dockerPublicKey = exports.dockerPrivateKey = exports.completeInstall = exports.askOrganizationReplication = exports.askIsGatewayOnlyMode = exports.askConfigType = exports.askBundleTypeGWOnly = exports.askBundleType = exports.EdgeInstallMethods = exports.EdgeGWOnlyInstallMethods = exports.ConfigFiles = void 0;
7
- var _cliKit = require("cli-kit");
8
- var _fs = _interopRequireDefault(require("fs"));
9
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
10
- var _basicPrompts = require("../../common/basicPrompts");
11
- var _dataService = require("../../common/dataService");
12
- var _Kubectl = require("../../common/Kubectl");
13
- var _types = require("../../common/types");
14
- var _utils = require("../../common/utils");
15
- var _agents = require("./agents");
16
- var helpers = _interopRequireWildcard(require("./helpers"));
17
- var _edgeTemplates = require("./helpers/templates/edgeTemplates");
18
- var _istioAgents = require("./istioAgents");
19
- 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); }
20
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
- const defaultLogFiles = '/group-*_instance-*.log';
22
- const defaultOTLogFiles = '/group-*_instance-*_traffic*.log';
23
- const dockerPrivateKey = exports.dockerPrivateKey = '/keys/private_key.pem';
24
- const dockerPublicKey = exports.dockerPublicKey = '/keys/public_key.pem';
25
-
26
- // @ts-ignore
27
- const {
28
- log
29
- } = (0, _snooplogg.default)('engage: install: agents: edge');
30
- const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.EDGE_DA}`;
31
- const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.EDGE_TA}`;
32
-
33
- // ConfigFiles - all the config file that are used in the setup
34
- const ConfigFiles = exports.ConfigFiles = {
35
- DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
36
- DAHelmOverride: 'da-overrides.yaml',
37
- EdgeDABinaryFile: 'discovery_agent',
38
- EdgeDAYaml: 'discovery_agent.yml',
39
- EdgeTABinaryFile: 'traceability_agent',
40
- EdgeTAYaml: 'traceability_agent.yml',
41
- TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`,
42
- TAHelmOverride: 'ta-overrides.yaml'
43
- };
44
- const prompts = exports.prompts = {
45
- configTypeMsg: 'Select the mode of installation',
46
- askApiGatewayHost: 'Enter the API Gateway hostname',
47
- askApiGatewayPort: 'Enter the API Gateway port',
48
- askApiManagerHost: 'Enter the API Manager hostname',
49
- askApiManagerPort: 'Enter the API Manager port',
50
- askLoggingSource: 'What is the source of logging for the traceability agent',
51
- askEventsPath: 'Enter the path to the API Gateway event log directory',
52
- askOpenTrafficPath: 'Enter the path to the API Gateway open traffic log directory',
53
- enterGatewayAgentNs: 'Enter the namespace to use for the Amplify Gateway Agents',
54
- enterGatewayManagerMode: 'Do you want to use API Manager with the API Gateway',
55
- askIfOrgReplication: 'Do you want to replicate your original organization structure for your newly discovered APIs? If yes, make sure the organization names match the team names that are created in Amplify platform'
56
- };
57
- const downloadV7AgentBundle = async (type, version) => {
58
- const fileName = type === _types.BundleType.DISCOVERY ? `discovery_agent-${version}.zip` : `traceability_agent-${version}.zip`;
59
- const url = type === _types.BundleType.DISCOVERY ? `/v7_discovery_agent/${version}/discovery_agent-${version}.zip` : `/v7_traceability_agent/${version}/traceability_agent-${version}.zip`;
60
- const service = await (0, _dataService.dataService)({
61
- baseUrl: _types.PublicRepoUrl,
62
- basePath: _types.BasePaths.V7Agents
63
- });
64
- try {
65
- const {
66
- stream
67
- } = await service.download(url);
68
- await helpers.streamPipeline(stream, _fs.default.createWriteStream(fileName));
69
- return fileName;
70
- } catch (err) {
71
- throw new Error(`Failed to download the agent: ${err.message}`);
72
- }
73
- };
74
- const downloadBinary = async (bundleType, version) => {
75
- const fileName = await downloadV7AgentBundle(bundleType, version);
76
- await helpers.unzip(fileName);
77
- _fs.default.unlinkSync(fileName);
78
- };
79
- const downloadBinaries = async installConfig => {
80
- console.log('Downloading and unpacking binary files...');
81
- if (installConfig.switches.isDaEnabled) {
82
- await downloadBinary(_types.BundleType.DISCOVERY, installConfig.daVersion);
83
- }
84
- if (installConfig.switches.isTaEnabled) {
85
- await downloadBinary(_types.BundleType.TRACEABILITY, installConfig.taVersion);
86
- }
87
- console.log('Downloading and unpacking is complete.');
88
- };
89
- const askIsGatewayOnlyMode = async () => {
90
- const mode = await (0, _basicPrompts.askList)({
91
- msg: prompts.enterGatewayManagerMode,
92
- default: _types.YesNo.Yes,
93
- choices: _types.YesNoChoices
94
- });
95
- return mode == _types.YesNo.Yes ? _types.GatewayTypes.EDGE_GATEWAY : _types.GatewayTypes.EDGE_GATEWAY_ONLY;
96
- };
97
- exports.askIsGatewayOnlyMode = askIsGatewayOnlyMode;
98
- const askOrganizationReplication = async () => {
99
- const mode = await (0, _basicPrompts.askList)({
100
- msg: prompts.askIfOrgReplication,
101
- default: _types.YesNo.Yes,
102
- choices: _types.YesNoChoices
103
- });
104
- return mode == _types.YesNo.Yes;
105
- };
106
- exports.askOrganizationReplication = askOrganizationReplication;
107
- const askBundleType = async () => {
108
- return await (0, _basicPrompts.askList)({
109
- msg: helpers.agentMessages.selectAgentType,
110
- choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY, _types.BundleType.TRACEABILITY]
111
- });
112
- };
113
- exports.askBundleType = askBundleType;
114
- const askBundleTypeGWOnly = async () => {
115
- return await (0, _basicPrompts.askList)({
116
- msg: helpers.agentMessages.selectAgentType,
117
- choices: [_types.BundleType.TRACEABILITY, _types.BundleType.TRACEABILITY_OFFLINE]
118
- });
119
- };
120
- exports.askBundleTypeGWOnly = askBundleTypeGWOnly;
121
- const askConfigType = async () => {
122
- return await (0, _basicPrompts.askList)({
123
- msg: prompts.configTypeMsg,
124
- choices: [_types.AgentConfigTypes.BINARIES, _types.AgentConfigTypes.DOCKERIZED, _types.AgentConfigTypes.HELM]
125
- });
126
- };
127
- exports.askConfigType = askConfigType;
128
- const askLoggingSource = async () => {
129
- console.log(_cliKit.chalk.white(`\nThe API Gateway can provide the API traffic either within event logs or open traffic logs.`));
130
- return (await (0, _basicPrompts.askList)({
131
- msg: prompts.askLoggingSource,
132
- default: _types.LoggingSource.Event,
133
- choices: [_types.LoggingSource.Event, _types.LoggingSource.OpenTraffic]
134
- })) === _types.LoggingSource.OpenTraffic;
135
- };
136
- const askEventsPath = async isOpenTraffic => {
137
- return await (0, _basicPrompts.askInput)({
138
- msg: isOpenTraffic ? prompts.askOpenTrafficPath : prompts.askEventsPath,
139
- defaultValue: isOpenTraffic ? '/apigateway/logs/opentraffic' : '/apigateway/events',
140
- type: 'string'
141
- });
142
- };
143
- const askApiManagerHost = async () => {
144
- return await (0, _basicPrompts.askInput)({
145
- msg: prompts.askApiManagerHost,
146
- defaultValue: _agents.localhost
147
- });
148
- };
149
- const askApiManagerPort = async () => {
150
- return await (0, _basicPrompts.askInput)({
151
- msg: prompts.askApiManagerPort,
152
- defaultValue: 8075,
153
- type: 'number'
154
- });
155
- };
156
- const askApiGatewayHost = async () => {
157
- return await (0, _basicPrompts.askInput)({
158
- msg: prompts.askApiGatewayHost,
159
- defaultValue: _agents.localhost
160
- });
161
- };
162
- const askApiGatewayPort = async () => {
163
- return await (0, _basicPrompts.askInput)({
164
- msg: prompts.askApiGatewayPort,
165
- defaultValue: 8090,
166
- type: 'number'
167
- });
168
- };
169
- const gatewayConnectivity = async installConfig => {
170
- let v7AgentValues = new _edgeTemplates.V7AgentValues();
171
- if (installConfig.switches.isHelmInstall) {
172
- const {
173
- error
174
- } = await _Kubectl.kubectl.isInstalled();
175
- if (error) {
176
- throw new Error(`Kubectl is required to fill out the following prompts. It appears to be missing or misconfigured.\n${error}`);
177
- }
178
- }
179
- if (!installConfig.switches.isGatewayOnly || installConfig.switches.isDaEnabled) {
180
- console.log('\nCONNECTION TO API MANAGER:');
181
- console.log(_cliKit.chalk.gray(`The agents need to connect to the Axway API Manager to discover APIs for publishing to Amplify.\n` + `Use the credentials of an API Manager Administrator user or an Organization Administrator user.`));
182
- if (installConfig.switches.isHelmInstall) {
183
- console.log(_cliKit.chalk.white(`Please use the name of the API Manager Service as hostname.`));
184
- }
185
- v7AgentValues.apiManagerHost = await askApiManagerHost();
186
- v7AgentValues.apiManagerPort = await askApiManagerPort();
187
- const apimCreds = await (0, _basicPrompts.askUsernameAndPassword)('the API Manager', 'apiadmin');
188
- v7AgentValues.apiManagerAuthUser = apimCreds.username;
189
- v7AgentValues.apiManagerAuthPass = apimCreds.password;
190
- }
191
- if (installConfig.switches.isTaEnabled) {
192
- v7AgentValues.isOpenTraffic = await askLoggingSource();
193
- if (!v7AgentValues.isOpenTraffic && installConfig.bundleType !== _types.BundleType.TRACEABILITY_OFFLINE) {
194
- console.log('\nCONNECTION TO API GATEWAY:');
195
- console.log(_cliKit.chalk.gray(`The traceability agent needs to connect to Axway API Gateway.\n` + `Use the credentials of an Operator user.`));
196
- if (installConfig.switches.isHelmInstall) {
197
- console.log(_cliKit.chalk.white(`Please use the name of the API Gateway Service as hostname.`));
198
- }
199
- v7AgentValues.apiGatewayHost = await askApiGatewayHost();
200
- v7AgentValues.apiGatewayPort = await askApiGatewayPort();
201
- const apigwCreds = await (0, _basicPrompts.askUsernameAndPassword)('the API Gateway', 'admin');
202
- v7AgentValues.apiGatewayAuthUser = apigwCreds.username;
203
- v7AgentValues.apiGatewayAuthPass = apigwCreds.password;
204
- }
205
- if (installConfig.switches.isBinaryInstall || installConfig.switches.isDockerInstall) {
206
- const eventLogPaths = await askEventsPath(v7AgentValues.isOpenTraffic);
207
- const trimmedDir = eventLogPaths.trim();
208
- v7AgentValues.eventLogPath = eventLogPaths ? trimmedDir[trimmedDir.length - 1] === '/' ? `${trimmedDir.slice(0, -1)}` : `${trimmedDir}` : '';
209
- v7AgentValues.eventLogPathTemplate = installConfig.switches.isBinaryInstall ? `${v7AgentValues.eventLogPath}${v7AgentValues.isOpenTraffic ? defaultOTLogFiles : defaultLogFiles}` : '';
210
- }
211
- }
212
- if (installConfig.switches.isHelmInstall) {
213
- v7AgentValues.namespace = await helpers.askNamespace(prompts.enterGatewayAgentNs, _istioAgents.amplifyAgentsNs);
214
- }
215
- return v7AgentValues;
216
- };
217
- exports.gatewayConnectivity = gatewayConnectivity;
218
- const generateSuccessHelpMsg = installConfig => {
219
- var _v7AgentValues$eventL;
220
- const v7AgentValues = installConfig.gatewayConfig;
221
- const configType = installConfig.deploymentType;
222
- const trimmedDir = (_v7AgentValues$eventL = v7AgentValues.eventLogPath) === null || _v7AgentValues$eventL === void 0 ? void 0 : _v7AgentValues$eventL.trim();
223
- const verifiedEventsPath = v7AgentValues.eventLogPath ? trimmedDir[trimmedDir.length - 1] === '/' ? `${trimmedDir.slice(0, -1)}:/events` : `${trimmedDir}:/events` : '';
224
- if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
225
- console.log(_cliKit.chalk.yellow('\nPlease make sure to copy the "private_key.pem" and "public_key.pem" files for the existing service account you selected.'));
226
- }
227
- if (configType === _types.AgentConfigTypes.BINARIES) {
228
- binarySuccessMsg(installConfig.centralConfig.ampcDosaInfo.isNew, installConfig.switches.isDaEnabled, installConfig.switches.isTaEnabled);
229
- } else if (configType === _types.AgentConfigTypes.DOCKERIZED) {
230
- dockerSuccessMsg(installConfig, verifiedEventsPath);
231
- } else if (installConfig.switches.isHelmInstall) {
232
- helmSuccessMsg(v7AgentValues.namespace.name, installConfig.switches.isDaEnabled, installConfig.switches.isTaEnabled);
233
- }
234
- console.log(_cliKit.chalk.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.V7}`));
235
- };
236
- const installPreprocess = async installConfig => {
237
- // Ask for key paths if HELM, and dosa NOT new
238
- if (installConfig.deploymentType === _types.AgentConfigTypes.HELM && !installConfig.centralConfig.ampcDosaInfo.isNew) {
239
- [installConfig.centralConfig.dosaAccount.publicKey, installConfig.centralConfig.dosaAccount.privateKey] = await helpers.askPublicAndPrivateKeysPath();
240
- }
241
-
242
- // attempt to download the binaries prior to creating resources
243
- if (installConfig.switches.isBinaryInstall) {
244
- await downloadBinaries(installConfig);
245
- }
246
- return installConfig;
247
- };
248
- exports.installPreprocess = installPreprocess;
249
- const completeInstall = async installConfig => {
250
- /**
251
- * Create agent resources
252
- */
253
- const v7AgentValues = installConfig.gatewayConfig;
254
-
255
- // Add final settings to v7AgentsValues
256
- v7AgentValues.centralConfig = installConfig.centralConfig;
257
- v7AgentValues.traceabilityConfig = installConfig.traceabilityConfig;
258
- v7AgentValues.isGatewayOnly = installConfig.switches.isGatewayOnly;
259
- v7AgentValues.daVersion = installConfig.daVersion;
260
- v7AgentValues.taVersion = installConfig.taVersion;
261
- if (installConfig.switches.isHelmInstall) {
262
- if (v7AgentValues.namespace.isNew) {
263
- await helpers.createNamespace(v7AgentValues.namespace.name);
264
- }
265
- await helpers.createSecret(v7AgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, async () => {
266
- if (installConfig.centralConfig.ampcDosaInfo.isNew) {
267
- console.log(_cliKit.chalk.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.`));
268
- }
269
- await helpers.createAmplifyAgentKeysSecret(v7AgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, 'public_key', v7AgentValues.centralConfig.dosaAccount.publicKey, 'private_key', v7AgentValues.centralConfig.dosaAccount.privateKey);
270
- });
271
- await helpers.createSecret(v7AgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, async () => {
272
- await helpers.createGatewayAgentCredsSecret(v7AgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, v7AgentValues.apiManagerAuthUser, v7AgentValues.apiManagerAuthPass, v7AgentValues.apiGatewayAuthUser, v7AgentValues.apiGatewayAuthPass);
273
- });
274
- }
275
- console.log('Generating the configuration file(s)...');
276
- if (installConfig.switches.isHelmInstall) {
277
- if (installConfig.switches.isDaEnabled) {
278
- (0, _utils.writeTemplates)(ConfigFiles.DAHelmOverride, v7AgentValues, helpers.v7DAHelmOverrideTemplate);
279
- }
280
- if (installConfig.switches.isTaEnabled) {
281
- (0, _utils.writeTemplates)(ConfigFiles.TAHelmOverride, v7AgentValues, helpers.v7TAHelmOverrideTemplate);
282
- }
283
- } else {
284
- if (installConfig.switches.isDaEnabled) {
285
- (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, v7AgentValues, helpers.v7DAEnvVarTemplate);
286
- }
287
- if (installConfig.switches.isTaEnabled) {
288
- (0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, v7AgentValues, helpers.v7TAEnvVarTemplate);
289
- }
290
- }
291
- console.log('Configuration file(s) have been successfully created.\n');
292
- generateSuccessHelpMsg(installConfig);
293
- };
294
- exports.completeInstall = completeInstall;
295
- const dockerSuccessMsg = (installConfig, eventLogPath) => {
296
- let dockerInfo;
297
- const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
298
- const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
299
- const runTaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
300
- const runTaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
301
- const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
302
- const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
303
- const startTaLinuxMsg = `\nStart the Traceability Agent on a Linux based machine`;
304
- const startTaWinMsg = `\nStart the Traceability Agent on a Windows machine`;
305
- if (installConfig.switches.isDaEnabled && installConfig.switches.isTaEnabled) {
306
- 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}):`;
307
- } else if (installConfig.switches.isDaEnabled) {
308
- dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
309
- } else {
310
- dockerInfo = `To utilize the traceability agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.TA_ENV_VARS}):`;
311
- }
312
- console.log(_cliKit.chalk.whiteBright(dockerInfo), '\n');
313
- if (installConfig.switches.isDaEnabled) {
314
- const daImageVersion = `${daImage}:${installConfig.daVersion}`;
315
- console.log(_cliKit.chalk.white('Pull the latest image of the Discovery Agent:'));
316
- console.log(_cliKit.chalk.cyan(`docker pull ${daImageVersion}`));
317
- console.log(_cliKit.chalk.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
318
- console.log(_cliKit.chalk.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
319
- console.log('\t', _cliKit.chalk.cyan(`-v /data ${daImageVersion}`));
320
- }
321
- if (installConfig.switches.isTaEnabled) {
322
- const taImageVersion = `${taImage}:${installConfig.taVersion}`;
323
- console.log(_cliKit.chalk.white('Pull the latest image of the Traceability Agent:'));
324
- console.log(_cliKit.chalk.cyan(`docker pull ${taImageVersion}`));
325
- console.log(_cliKit.chalk.white(_utils.isWindows ? startTaWinMsg : startTaLinuxMsg));
326
- console.log(_cliKit.chalk.cyan(_utils.isWindows ? runTaWinMsg : runTaLinuxMsg));
327
- console.log('\t', _cliKit.chalk.cyan(`-v ${eventLogPath} -v /data ${taImageVersion}`));
328
- }
329
- };
330
- const binarySuccessMsg = (isNewDosa, isDaEnabled, isTaEnabled) => {
331
- const daFiles = [ConfigFiles.DAEnvVars, ConfigFiles.EdgeDABinaryFile, ConfigFiles.EdgeDAYaml];
332
- const taFiles = [ConfigFiles.TAEnvVars, ConfigFiles.EdgeTABinaryFile, ConfigFiles.EdgeTAYaml];
333
- const keys = ['private_key.pem', 'public_key.pem'];
334
- let files = [];
335
- if (isNewDosa) {
336
- files = files.concat(keys);
337
- }
338
- if (isDaEnabled) {
339
- files = files.concat(daFiles);
340
- }
341
- if (isTaEnabled) {
342
- files = files.concat(taFiles);
343
- }
344
- const agents = isDaEnabled && isTaEnabled ? 'agents' : 'agent';
345
- console.log(_cliKit.chalk.whiteBright('Please copy following files from current folder to API Gateway machine:'));
346
- console.log(_cliKit.chalk.cyan(files.join('\n')));
347
- console.log(_cliKit.chalk.whiteBright('for example'), _cliKit.chalk.cyan(`scp ${files.join(' ')} root@host:~/some_folder/`));
348
- console.log(_cliKit.chalk.whiteBright(`\nTo start the ${agents}:`));
349
- if (isDaEnabled) {
350
- console.log(_cliKit.chalk.cyan(`./discovery_agent --envFile ./${helpers.configFiles.DA_ENV_VARS}`));
351
- }
352
- if (isTaEnabled) {
353
- console.log(_cliKit.chalk.cyan(`./traceability_agent --envFile ./${helpers.configFiles.TA_ENV_VARS}`));
354
- }
355
- };
356
- const helmSuccessMsg = (namespace, isDaEnabled, isTaEnabled) => {
357
- const imagePullOverrides = `--set image.pullSecret=<image-pull-secret-name>`;
358
- let agentHelmInfo = new Set();
359
- if (isDaEnabled) {
360
- console.log(_cliKit.chalk.white(`Discovery Agent override file has been placed at ${process.cwd()}/${ConfigFiles.DAHelmOverride}`));
361
- agentHelmInfo.add({
362
- helmReleaseName: 'v7-discovery',
363
- helmChartName: 'axway/v7-discovery',
364
- overrideFileName: ConfigFiles.DAHelmOverride,
365
- imageSecretOverrides: imagePullOverrides
366
- });
367
- }
368
- if (isTaEnabled) {
369
- console.log(_cliKit.chalk.white(`Traceability Agent override file has been placed at ${process.cwd()}/${ConfigFiles.TAHelmOverride}`));
370
- agentHelmInfo.add({
371
- helmReleaseName: 'v7-traceability',
372
- helmChartName: 'axway/v7-traceability',
373
- overrideFileName: ConfigFiles.TAHelmOverride,
374
- imageSecretOverrides: imagePullOverrides
375
- });
376
- }
377
- helpers.helmImageSecretInfo(namespace);
378
- helpers.helmInstallInfo('Edge', namespace, agentHelmInfo);
379
- };
380
- const edgeAgentNameMap = {
381
- [_types.AgentTypes.da]: _types.AgentNames.EDGE_DA,
382
- [_types.AgentTypes.ta]: _types.AgentNames.EDGE_TA
383
- };
384
- const EdgeInstallMethods = exports.EdgeInstallMethods = {
385
- GetBundleType: askBundleType,
386
- GetDeploymentType: askConfigType,
387
- AskGatewayQuestions: gatewayConnectivity,
388
- InstallPreprocess: installPreprocess,
389
- FinalizeGatewayInstall: completeInstall,
390
- ConfigFiles: Object.values(ConfigFiles),
391
- AgentNameMap: edgeAgentNameMap,
392
- GatewayDisplay: _types.GatewayTypes.EDGE_GATEWAY
393
- };
394
- const EdgeGWOnlyInstallMethods = exports.EdgeGWOnlyInstallMethods = {
395
- GetBundleType: askBundleTypeGWOnly,
396
- GetDeploymentType: askConfigType,
397
- AskGatewayQuestions: gatewayConnectivity,
398
- InstallPreprocess: installPreprocess,
399
- FinalizeGatewayInstall: completeInstall,
400
- ConfigFiles: Object.values(ConfigFiles),
401
- AgentNameMap: edgeAgentNameMap,
402
- GatewayDisplay: _types.GatewayTypes.EDGE_GATEWAY
403
- };
404
- const testables = exports.testables = {
405
- prompts,
406
- ConfigFiles,
407
- defaultLogFiles,
408
- defaultOTLogFiles
409
- };