@axway/axway-central-cli 2.17.0 → 2.18.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 (58) hide show
  1. package/dist/cli.js +6 -28
  2. package/dist/commands/apply/index.js +9 -24
  3. package/dist/commands/completion/index.js +3 -9
  4. package/dist/commands/config/common/index.js +2 -11
  5. package/dist/commands/config/index.js +2 -7
  6. package/dist/commands/config/list.js +2 -6
  7. package/dist/commands/config/set.js +4 -31
  8. package/dist/commands/config/unset.js +2 -12
  9. package/dist/commands/create/agentResource.js +12 -32
  10. package/dist/commands/create/environment.js +6 -16
  11. package/dist/commands/create/index.js +9 -26
  12. package/dist/commands/create/serviceAccount.js +2 -6
  13. package/dist/commands/delete/index.js +15 -33
  14. package/dist/commands/edit/environment.js +6 -21
  15. package/dist/commands/edit/index.js +4 -8
  16. package/dist/commands/get/index.js +27 -44
  17. package/dist/commands/install/agents.js +41 -70
  18. package/dist/commands/install/apigeexSaasAgents.js +33 -96
  19. package/dist/commands/install/awsAgents.js +87 -137
  20. package/dist/commands/install/awsSaasAgents.js +48 -140
  21. package/dist/commands/install/azureAgents.js +37 -77
  22. package/dist/commands/install/edgeAgents.js +15 -108
  23. package/dist/commands/install/gitHubSaasAgents.js +286 -0
  24. package/dist/commands/install/helpers/creators.js +17 -70
  25. package/dist/commands/install/helpers/deleters.js +2 -11
  26. package/dist/commands/install/helpers/getters.js +4 -30
  27. package/dist/commands/install/helpers/index.js +13 -48
  28. package/dist/commands/install/helpers/inputs.js +26 -98
  29. package/dist/commands/install/helpers/regex.js +29 -34
  30. package/dist/commands/install/helpers/templates/awsTemplates.js +6 -23
  31. package/dist/commands/install/helpers/templates/azureTemplates.js +5 -24
  32. package/dist/commands/install/helpers/templates/edgeTemplates.js +7 -38
  33. package/dist/commands/install/helpers/templates/istioTemplates.js +5 -16
  34. package/dist/commands/install/index.js +4 -10
  35. package/dist/commands/install/istioAgents.js +38 -115
  36. package/dist/commands/install/platform.js +18 -50
  37. package/dist/commands/proxies/create.js +2 -18
  38. package/dist/commands/proxies/index.js +4 -8
  39. package/dist/commands/proxies/promote.js +2 -21
  40. package/dist/common/ApiServerClient.js +64 -173
  41. package/dist/common/CacheController.js +11 -32
  42. package/dist/common/CliConfigManager.js +14 -27
  43. package/dist/common/CompositeError.js +6 -30
  44. package/dist/common/CoreConfigController.js +18 -40
  45. package/dist/common/DefinitionsManager.js +29 -76
  46. package/dist/common/Kubectl.js +2 -25
  47. package/dist/common/PlatformClient.js +19 -63
  48. package/dist/common/Renderer.js +25 -87
  49. package/dist/common/TmpFile.js +11 -28
  50. package/dist/common/bashCommands.js +3 -22
  51. package/dist/common/basicPrompts.js +8 -43
  52. package/dist/common/dataService.js +22 -50
  53. package/dist/common/errorHandler.js +0 -9
  54. package/dist/common/resultsRenderers.js +10 -42
  55. package/dist/common/types.js +117 -342
  56. package/dist/common/utils.js +37 -99
  57. package/dist/main.js +0 -2
  58. package/package.json +2 -2
@@ -4,94 +4,66 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.prompts = exports.localhost = exports.agents = void 0;
7
-
8
7
  var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
11
-
12
9
  var _ApiServerClient = require("../../common/ApiServerClient");
13
-
14
10
  var _basicPrompts = require("../../common/basicPrompts");
15
-
16
11
  var _CoreConfigController = require("../../common/CoreConfigController");
17
-
18
12
  var _DefinitionsManager = require("../../common/DefinitionsManager");
19
-
20
13
  var _PlatformClient = require("../../common/PlatformClient");
21
-
22
14
  var _CliConfigManager = require("../../common/CliConfigManager");
23
-
24
15
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
25
-
26
16
  var _types = require("../../common/types");
27
-
28
17
  var _utils = require("../../common/utils");
29
-
30
18
  var awsAgents = _interopRequireWildcard(require("./awsAgents"));
31
-
19
+ var gitHubAgents = _interopRequireWildcard(require("./gitHubSaasAgents"));
32
20
  var azureAgents = _interopRequireWildcard(require("./azureAgents"));
33
-
34
21
  var edgeAgents = _interopRequireWildcard(require("./edgeAgents"));
35
-
36
22
  var apigeeSaaSAgents = _interopRequireWildcard(require("./apigeexSaasAgents"));
37
-
38
23
  var helpers = _interopRequireWildcard(require("./helpers"));
39
-
40
24
  var istioAgents = _interopRequireWildcard(require("./istioAgents"));
41
-
42
25
  var saasAgents = _interopRequireWildcard(require("./awsSaasAgents"));
43
-
44
26
  var platform = _interopRequireWildcard(require("./platform"));
45
-
46
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
47
-
48
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
49
-
50
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
-
52
30
  const {
53
31
  log
54
32
  } = (0, _snooplogg.default)('central: install: agents');
55
- const localhost = 'localhost';
56
- exports.localhost = localhost;
57
- const prompts = {
33
+ const localhost = exports.localhost = 'localhost';
34
+ const prompts = exports.prompts = {
58
35
  hostedAgentOption: 'Will this be an embedded agent',
59
36
  selectGatewayType: 'Select the type of gateway you want to connect'
60
37
  };
61
- exports.prompts = prompts;
62
38
  const agentInstallFlows = {
63
39
  [_types.GatewayTypes.EDGE_GATEWAY]: edgeAgents.EdgeInstallMethods,
64
40
  [_types.GatewayTypes.EDGE_GATEWAY_ONLY]: edgeAgents.EdgeGWOnlyInstallMethods,
65
41
  [_types.GatewayTypes.AWS_GATEWAY]: awsAgents.AWSInstallMethods,
42
+ [_types.GatewayTypes.GITHUB]: gitHubAgents.GitHubSaaSInstallMethods,
66
43
  [_types.GatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods,
67
44
  [_types.GatewayTypes.AZURE_GATEWAY]: azureAgents.AzureInstallMethods,
68
45
  [_types.GatewayTypes.ISTIO]: istioAgents.IstioInstallMethods
69
46
  };
70
47
  const saasAgentInstallFlows = {
71
48
  [_types.GatewayTypes.AWS_GATEWAY]: saasAgents.AWSSaaSInstallMethods,
49
+ [_types.GatewayTypes.GITHUB]: gitHubAgents.GitHubSaaSInstallMethods,
72
50
  [_types.GatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods
73
51
  };
74
-
75
52
  const createConfigBackup = async (configFiles, gatewayType) => {
76
53
  // If current configurations exist, back them up
77
54
  const configsExist = await helpers.createBackUpConfigs(configFiles);
78
-
79
55
  if (configsExist) {
80
56
  console.log(`\nCreated configuration backups for ${gatewayType}`);
81
57
  }
82
58
  };
83
-
84
59
  const determineRegion = async region => {
85
60
  let configurationRegion = (await (0, _utils.getConfig)())[_CliConfigManager.CliConfigKeys.REGION];
86
-
87
61
  if (region) {
88
62
  return region.toString();
89
63
  }
90
-
91
64
  return configurationRegion ? configurationRegion : _types.Regions.US;
92
65
  };
93
-
94
- const agents = {
66
+ const agents = exports.agents = {
95
67
  action: async function ({
96
68
  argv,
97
69
  console
@@ -106,10 +78,8 @@ const agents = {
106
78
  } = argv;
107
79
  let isCmdError = false;
108
80
  const render = new _Renderer.default(console);
109
-
110
81
  try {
111
82
  var _accountInfo$roles, _accountInfo$roles2;
112
-
113
83
  // initialize clients
114
84
  const apiServerClient = new _ApiServerClient.ApiServerClient({
115
85
  baseUrl,
@@ -122,24 +92,26 @@ const agents = {
122
92
  account,
123
93
  region
124
94
  });
125
- const defsManager = await new _DefinitionsManager.DefinitionsManager(apiServerClient).init(); // Verify account has permission to create an environment and service account.
95
+ const defsManager = await new _DefinitionsManager.DefinitionsManager(apiServerClient).init();
126
96
 
97
+ // Verify account has permission to create an environment and service account.
127
98
  const accountInfo = await platformClient.getAccountInfo();
128
99
  const isCentralAdmin = accountInfo === null || accountInfo === void 0 ? void 0 : (_accountInfo$roles = accountInfo.roles) === null || _accountInfo$roles === void 0 ? void 0 : _accountInfo$roles.includes(_CoreConfigController.AccountRole.ApiCentralAdmin);
129
100
  const isPlatformAdmin = accountInfo === null || accountInfo === void 0 ? void 0 : (_accountInfo$roles2 = accountInfo.roles) === null || _accountInfo$roles2 === void 0 ? void 0 : _accountInfo$roles2.includes(_CoreConfigController.AccountRole.PlatformAdmin);
130
- checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render); // helper text
101
+ checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render);
131
102
 
103
+ // helper text
132
104
  console.log(_chalk.default.gray(`This command configures and installs the agents so that you can manage your gateway environment within the Amplify Platform.\n`));
133
105
  let installConfig = new _types.AgentInstallConfig();
134
- installConfig.centralConfig.axwayManaged = !!axwayManaged; // top priority is region option on command line, second priority is region from config file, default is US
106
+ installConfig.centralConfig.axwayManaged = !!axwayManaged;
135
107
 
108
+ // top priority is region option on command line, second priority is region from config file, default is US
136
109
  installConfig.centralConfig.region = await determineRegion(region);
137
110
  installConfig.centralConfig.singleEntryPointUrl = _types.SingleEntryPointUrls[installConfig.centralConfig.region];
138
111
  let gatewayType = await (0, _basicPrompts.askList)({
139
112
  msg: prompts.selectGatewayType,
140
113
  choices: Object.values(_types.GatewayTypes).filter(v => v !== _types.GatewayTypes.EDGE_GATEWAY_ONLY)
141
114
  });
142
-
143
115
  if (gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
144
116
  // hosted vs on premise
145
117
  installConfig.switches.isHostedInstall = (await (0, _basicPrompts.askList)({
@@ -148,55 +120,59 @@ const agents = {
148
120
  default: _types.YesNo.Yes
149
121
  })) === _types.YesNo.Yes;
150
122
  }
151
-
152
- if (gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
123
+ if (gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY || gatewayType === _types.GatewayTypes.GITHUB) {
153
124
  installConfig.switches.isHostedInstall = true;
154
- } // if gateway type is edge ask Gateway only or not
155
-
125
+ }
156
126
 
127
+ // if gateway type is edge ask Gateway only or not
157
128
  if (gatewayType === _types.GatewayTypes.EDGE_GATEWAY) {
158
129
  installConfig.switches.isGatewayOnly = false;
159
130
  gatewayType = await edgeAgents.askIsGatewayOnlyMode();
160
131
  }
161
-
162
132
  installConfig.switches.isGatewayOnly = gatewayType === _types.GatewayTypes.EDGE_GATEWAY_ONLY;
163
133
  installConfig.gatewayType = gatewayType;
164
134
  let agentInstallFlow = agentInstallFlows[installConfig.gatewayType];
165
-
166
135
  if (installConfig.switches.isHostedInstall) {
167
136
  agentInstallFlow = saasAgentInstallFlows[installConfig.gatewayType];
168
- } // Create the object of GatewayTypes -> BundleType functions
169
-
137
+ }
170
138
 
139
+ // Create the object of GatewayTypes -> BundleType functions
171
140
  installConfig.bundleType = await agentInstallFlow.GetBundleType();
172
141
  installConfig.switches.isDaEnabled = installConfig.bundleType === _types.BundleType.ALL_AGENTS || installConfig.bundleType === _types.BundleType.DISCOVERY;
173
- installConfig.switches.isTaEnabled = installConfig.bundleType === _types.BundleType.ALL_AGENTS || installConfig.bundleType === _types.BundleType.TRACEABILITY || installConfig.bundleType === _types.BundleType.TRACEABILITY_OFFLINE; // Create the object of GatewayTypes -> BundleType functions
142
+ installConfig.switches.isTaEnabled = installConfig.bundleType === _types.BundleType.ALL_AGENTS || installConfig.bundleType === _types.BundleType.TRACEABILITY || installConfig.bundleType === _types.BundleType.TRACEABILITY_OFFLINE;
174
143
 
144
+ // Create the object of GatewayTypes -> BundleType functions
175
145
  installConfig.deploymentType = await agentInstallFlow.GetDeploymentType();
176
146
  installConfig.switches.isHelmInstall = installConfig.deploymentType === _types.AgentConfigTypes.HELM;
177
147
  installConfig.switches.isDockerInstall = installConfig.deploymentType === _types.AgentConfigTypes.DOCKERIZED;
178
- installConfig.switches.isBinaryInstall = installConfig.deploymentType === _types.AgentConfigTypes.BINARIES; // Get the version of the agents from jfrog, not needed in hosted install
148
+ installConfig.switches.isBinaryInstall = installConfig.deploymentType === _types.AgentConfigTypes.BINARIES;
179
149
 
180
- await getAgentVersions(agentInstallFlow, installConfig); // if EDGE_GATEWAY or EDGE_GATEWAY_ONLY and isDaEnabled, ask if the organization structure should replicate
150
+ // Get the version of the agents from jfrog, not needed in hosted install
151
+ await getAgentVersions(agentInstallFlow, installConfig);
181
152
 
153
+ // if EDGE_GATEWAY or EDGE_GATEWAY_ONLY and isDaEnabled, ask if the organization structure should replicate
182
154
  if ((gatewayType === _types.GatewayTypes.EDGE_GATEWAY || gatewayType === _types.GatewayTypes.EDGE_GATEWAY_ONLY) && installConfig.switches.isDaEnabled) {
183
155
  installConfig.switches.isOrgRep = await edgeAgents.askOrganizationReplication();
184
- } // get platform connectivity
185
-
156
+ }
186
157
 
187
- installConfig.centralConfig = await platform.getCentralConfig(apiServerClient, platformClient, defsManager, apicDeployment, installConfig); // Create the object of GatewayTypes -> GatewayConnectivity functions
158
+ // get platform connectivity
159
+ installConfig.centralConfig = await platform.getCentralConfig(apiServerClient, platformClient, defsManager, apicDeployment, installConfig);
188
160
 
189
- installConfig.gatewayConfig = await agentInstallFlow.AskGatewayQuestions(installConfig, apiServerClient, defsManager); // traceability options
161
+ // Create the object of GatewayTypes -> GatewayConnectivity functions
162
+ installConfig.gatewayConfig = await agentInstallFlow.AskGatewayQuestions(installConfig, apiServerClient, defsManager);
190
163
 
164
+ // traceability options
191
165
  if (installConfig.switches.isTaEnabled && !installConfig.switches.isHostedInstall) {
192
166
  installConfig.traceabilityConfig = await platform.getTraceabilityConfig(installConfig);
193
- } // create backup
194
-
167
+ }
195
168
 
196
- await createConfigBackup(agentInstallFlow.ConfigFiles, agentInstallFlow.GatewayDisplay); // run any install preprocess steps
169
+ // create backup
170
+ await createConfigBackup(agentInstallFlow.ConfigFiles, agentInstallFlow.GatewayDisplay);
197
171
 
198
- installConfig = await finishInstall(agentInstallFlow, installConfig, apiServerClient, platformClient, defsManager); // finalize gateway setup and output
172
+ // run any install preprocess steps
173
+ installConfig = await finishInstall(agentInstallFlow, installConfig, apiServerClient, platformClient, defsManager);
199
174
 
175
+ // finalize gateway setup and output
200
176
  await agentInstallFlow.FinalizeGatewayInstall(installConfig, apiServerClient, defsManager);
201
177
  } catch (e) {
202
178
  log('command error', e);
@@ -204,37 +180,33 @@ const agents = {
204
180
  render.anyError(e);
205
181
  } finally {
206
182
  log('command complete');
207
- if (isCmdError) process.exit(1); // not sure why explicit exit is needed, seems like download is causing it to hang for 10-20 sec
208
-
183
+ if (isCmdError) process.exit(1);
184
+ // not sure why explicit exit is needed, seems like download is causing it to hang for 10-20 sec
209
185
  process.exit(0);
210
186
  }
211
187
  },
212
188
  desc: 'Amplify API Gateway / Amazon API Gateway / Azure API Gateway / Istio',
213
- options: { ..._types.commonCmdArgsDescription
189
+ options: {
190
+ ..._types.commonCmdArgsDescription
214
191
  }
215
192
  };
216
- exports.agents = agents;
217
-
218
193
  async function getAgentVersions(agentInstallFlow, installConfig) {
219
194
  if (agentInstallFlow.AgentNameMap && !installConfig.switches.isHostedInstall && installConfig.switches.isDaEnabled) {
220
195
  installConfig.daVersion = await helpers.getLatestAgentVersion(agentInstallFlow.AgentNameMap[_types.AgentTypes.da]);
221
196
  }
222
-
223
197
  if (agentInstallFlow.AgentNameMap && !installConfig.switches.isHostedInstall && installConfig.switches.isTaEnabled) {
224
198
  installConfig.taVersion = await helpers.getLatestAgentVersion(agentInstallFlow.AgentNameMap[_types.AgentTypes.ta]);
225
199
  }
226
200
  }
227
-
228
201
  async function finishInstall(agentInstallFlow, installConfig, apiServerClient, platformClient, defsManager) {
229
- if (agentInstallFlow.InstallPreprocess) installConfig = await agentInstallFlow.InstallPreprocess(installConfig); // finalize Platform setup, only for non-hosted agents
202
+ if (agentInstallFlow.InstallPreprocess) installConfig = await agentInstallFlow.InstallPreprocess(installConfig);
230
203
 
204
+ // finalize Platform setup, only for non-hosted agents
231
205
  if (!installConfig.switches.isHostedInstall) {
232
206
  installConfig = await platform.finalizeCentralInstall(apiServerClient, platformClient, defsManager, installConfig);
233
207
  }
234
-
235
208
  return installConfig;
236
209
  }
237
-
238
210
  function checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render) {
239
211
  if (!isCentralAdmin || !isPlatformAdmin) {
240
212
  if (!accountInfo || accountInfo.isPlatform) {
@@ -243,7 +215,6 @@ function checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render) {
243
215
  render.error('Error: Not authorized. "Service Account" must be authorized with a user account with "Tooling Credentials" assigned the roles: Platform Admin, Central Admin');
244
216
  render.error('See: https://docs.axway.com/bundle/axwaycli-open-docs/page/docs/authentication/index.html#service-account-with-username-password');
245
217
  }
246
-
247
218
  process.exit(1);
248
219
  }
249
220
  }
@@ -4,94 +4,61 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.testables = exports.askBundleType = exports.APIGEEXSaaSInstallMethods = void 0;
7
-
8
7
  var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
11
-
12
9
  var _basicPrompts = require("../../common/basicPrompts");
13
-
14
10
  var _types = require("../../common/types");
15
-
16
11
  var helpers = _interopRequireWildcard(require("./helpers"));
17
-
18
12
  var _crypto = _interopRequireDefault(require("crypto"));
19
-
20
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
28
19
  const {
29
20
  log
30
21
  } = (0, _snooplogg.default)('central: install: agents: saas');
31
-
32
22
  class DataplaneConfig {
33
23
  constructor(type) {
34
24
  _defineProperty(this, "type", void 0);
35
-
36
25
  this.type = type || "";
37
26
  }
38
-
39
27
  }
40
-
41
28
  class APIGEEXDataplaneConfig extends DataplaneConfig {
42
29
  constructor(projectID, developerEmail, mode) {
43
30
  super("Apigee");
44
-
45
31
  _defineProperty(this, "projectId", void 0);
46
-
47
32
  _defineProperty(this, "developerEmail", void 0);
48
-
49
33
  _defineProperty(this, "mode", void 0);
50
-
51
34
  this.projectId = projectID;
52
35
  this.developerEmail = developerEmail;
53
36
  this.mode = mode;
54
37
  }
55
-
56
38
  }
57
-
58
39
  class SaasAgentValues {
59
40
  constructor() {
60
41
  _defineProperty(this, "frequencyDA", void 0);
61
-
62
42
  _defineProperty(this, "queueDA", void 0);
63
-
64
43
  _defineProperty(this, "frequencyTA", void 0);
65
-
66
44
  _defineProperty(this, "dataplaneConfig", void 0);
67
-
68
45
  _defineProperty(this, "centralConfig", void 0);
69
-
70
46
  this.frequencyDA = '';
71
47
  this.queueDA = false;
72
48
  this.frequencyTA = '';
73
49
  this.dataplaneConfig = new DataplaneConfig();
74
50
  this.centralConfig = new _types.CentralAgentConfig();
75
51
  }
76
-
77
52
  }
78
-
79
53
  class SaasAPIGEEXAgentValues extends SaasAgentValues {
80
54
  constructor() {
81
55
  super();
82
-
83
56
  _defineProperty(this, "authType", void 0);
84
-
85
57
  _defineProperty(this, "clientEmailAddress", void 0);
86
-
87
58
  _defineProperty(this, "credentialJSON", void 0);
88
-
89
59
  _defineProperty(this, "projectId", void 0);
90
-
91
60
  _defineProperty(this, "developerEmailAddress", void 0);
92
-
93
61
  _defineProperty(this, "mode", void 0);
94
-
95
62
  this.authType = APIGEEXAuthType.IMP_SVC_ACC;
96
63
  this.clientEmailAddress = '';
97
64
  this.credentialJSON = '';
@@ -99,31 +66,26 @@ class SaasAPIGEEXAgentValues extends SaasAgentValues {
99
66
  this.developerEmailAddress = '';
100
67
  this.mode = _types.APIGEEXDISCOVERYMODES.PROXY;
101
68
  }
102
-
103
69
  getAccessData() {
104
70
  let data = JSON.stringify({
105
71
  client_email: this.clientEmailAddress
106
72
  });
107
-
108
73
  if (this.authType == APIGEEXAuthType.ACCESS_CREDENTIAL) {
109
74
  data = JSON.stringify(this.credentialJSON);
110
75
  }
111
-
112
76
  return data;
113
77
  }
78
+ }
114
79
 
115
- } // ConfigFiles - all the config file that are used in the setup
116
-
117
-
118
- const ConfigFiles = {}; // APIGEEXAuthType - how the agent will authenticate to APIGEEX
119
-
120
- var APIGEEXAuthType; // APIGEEX SaaSPrompts - all APIGEEX Saas prompts to the user for input
80
+ // ConfigFiles - all the config file that are used in the setup
81
+ const ConfigFiles = {};
121
82
 
122
- (function (APIGEEXAuthType) {
83
+ // APIGEEXAuthType - how the agent will authenticate to APIGEEX
84
+ var APIGEEXAuthType = /*#__PURE__*/function (APIGEEXAuthType) {
123
85
  APIGEEXAuthType["IMP_SVC_ACC"] = "Impersonate Service Account";
124
86
  APIGEEXAuthType["ACCESS_CREDENTIAL"] = "Access Credential";
125
- })(APIGEEXAuthType || (APIGEEXAuthType = {}));
126
-
87
+ return APIGEEXAuthType;
88
+ }(APIGEEXAuthType || {}); // APIGEEX SaaSPrompts - all APIGEEX Saas prompts to the user for input
127
89
  const SaasPrompts = {
128
90
  AUTHENTICATION_TYPE: 'Authenticate with an Impersonation of a Service Account or by providing a Credential File',
129
91
  PROJECT_ID: 'Enter the APIGEE X Project ID the agent will use',
@@ -135,28 +97,25 @@ const SaasPrompts = {
135
97
  QUEUE: 'Do you want to discover immediately after installation',
136
98
  ENTER_MORE: 'Do you want to enter another {0} for {1}'
137
99
  };
138
-
139
100
  const askBundleType = async () => {
140
101
  return await (0, _basicPrompts.askList)({
141
102
  msg: helpers.agentMessages.selectAgentType,
142
103
  choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
143
104
  });
144
105
  };
145
-
146
106
  exports.askBundleType = askBundleType;
147
-
148
107
  const askConfigType = async () => {
149
108
  return _types.AgentConfigTypes.HOSTED;
150
109
  };
151
-
152
110
  const askForAPIGEEXCredentials = async hostedAgentValues => {
153
111
  log("gathering access details for apigee x");
154
112
  hostedAgentValues.projectId = await (0, _basicPrompts.askInput)({
155
113
  msg: SaasPrompts.PROJECT_ID,
156
114
  defaultValue: hostedAgentValues.projectId !== '' ? hostedAgentValues.projectId : undefined,
157
115
  validate: (0, _basicPrompts.validateRegex)(helpers.APIGEEXRegexPatterns.APIGEEX_REGEXP_PROJECT_ID, helpers.invalidValueExampleErrMsg('Project ID', 'rd-amplify-apigee-x'))
158
- }); // get developer email address
116
+ });
159
117
 
118
+ // get developer email address
160
119
  hostedAgentValues.developerEmailAddress = await (0, _basicPrompts.askInput)({
161
120
  msg: SaasPrompts.DEVELOPER_EMAIL_ADDRESS,
162
121
  defaultValue: hostedAgentValues.developerEmailAddress !== '' ? hostedAgentValues.developerEmailAddress : undefined,
@@ -164,55 +123,47 @@ const askForAPIGEEXCredentials = async hostedAgentValues => {
164
123
  });
165
124
  hostedAgentValues.authType = APIGEEXAuthType.IMP_SVC_ACC;
166
125
  console.log(_chalk.default.gray("Please refer to docs.axway.com for information on creating the necessary APIGEE X IAM policies"));
167
-
168
126
  if (hostedAgentValues.authType === APIGEEXAuthType.IMP_SVC_ACC) {
169
- log("using impersonate service account authentication"); // get client email address
170
-
127
+ log("using impersonate service account authentication");
128
+ // get client email address
171
129
  hostedAgentValues.clientEmailAddress = await (0, _basicPrompts.askInput)({
172
130
  msg: SaasPrompts.CLIENT_EMAIL_ADDRESS,
173
131
  defaultValue: hostedAgentValues.clientEmailAddress !== '' ? hostedAgentValues.clientEmailAddress : undefined,
174
132
  allowEmptyInput: true
175
133
  });
176
134
  }
177
-
178
135
  return hostedAgentValues;
179
136
  };
180
-
181
137
  const validateFrequency = () => input => {
182
138
  let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
183
-
184
139
  if (typeof val === "string") {
185
140
  return val;
186
141
  }
187
-
188
142
  let r = input.toString().match(/^(\d*)m/);
189
-
190
143
  if (r) {
191
144
  // only minutes
192
145
  let mins = r[1];
193
-
194
146
  if (parseInt(mins, 10) < 30) {
195
147
  return "Minimum frequency is 30m";
196
148
  }
197
149
  }
198
-
199
150
  return true;
200
- }; // @ts-ignore
201
-
151
+ };
202
152
 
153
+ // @ts-ignore
203
154
  const gatewayConnectivity = async installConfig => {
204
155
  console.log('\nCONNECTION TO APIGEE X API GATEWAY:');
205
- console.log(_chalk.default.gray("The Discovery Agent needs to connect to the APIGEE X API Gateway to discover API's for publishing to Amplify Central")); // DeploymentType
156
+ console.log(_chalk.default.gray("The Discovery Agent needs to connect to the APIGEE X API Gateway to discover API's for publishing to Amplify Central"));
206
157
 
158
+ // DeploymentType
207
159
  let hostedAgentValues = new SaasAgentValues();
208
-
209
160
  if (installConfig.gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
210
161
  // APIGEE X connection details
211
162
  hostedAgentValues = new SaasAPIGEEXAgentValues();
212
163
  hostedAgentValues = await askForAPIGEEXCredentials(hostedAgentValues);
213
- } // Ask to queue discovery now
214
-
164
+ }
215
165
 
166
+ // Ask to queue discovery now
216
167
  log("getting the frequency and if the agent should run now");
217
168
  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."));
218
169
  hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
@@ -225,7 +176,6 @@ const gatewayConnectivity = async installConfig => {
225
176
  default: _types.YesNo.No,
226
177
  choices: _types.YesNoChoices
227
178
  })) === _types.YesNo.Yes;
228
-
229
179
  if (installConfig.switches.isTaEnabled) {
230
180
  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."));
231
181
  hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
@@ -235,70 +185,59 @@ const gatewayConnectivity = async installConfig => {
235
185
  allowEmptyInput: true
236
186
  });
237
187
  }
238
-
239
188
  return hostedAgentValues;
240
189
  };
241
-
242
190
  const generateOutput = async installConfig => {
243
191
  return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
244
192
  };
245
-
246
193
  const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
247
194
  var _dataplaneRes$securit, _dataplaneRes$securit2;
248
-
249
195
  // grab key from data plane resource
250
196
  let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
251
197
  let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
252
-
253
198
  if (key === "" || hash === "") {
254
199
  throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
255
200
  }
256
-
257
201
  let encData = _crypto.default.publicEncrypt({
258
202
  key: key,
259
203
  padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
260
204
  oaepHash: hash
261
205
  }, Buffer.from(hostedAgentValues.getAccessData()));
262
-
263
206
  return encData.toString("base64");
264
207
  };
265
-
266
208
  const completeInstall = async (installConfig, apiServerClient, defsManager) => {
267
209
  /**
268
210
  * Create agent resources
269
211
  */
270
212
  console.log("\n");
271
- let apigeeXAgentValues = installConfig.gatewayConfig; // create the environment, if necessary
213
+ let apigeeXAgentValues = installConfig.gatewayConfig;
272
214
 
215
+ // create the environment, if necessary
273
216
  installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
274
217
  axwayManaged: installConfig.centralConfig.axwayManaged,
275
218
  production: installConfig.centralConfig.production
276
219
  }) : installConfig.centralConfig.ampcEnvInfo.name;
277
-
278
220
  if (installConfig.gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
279
221
  apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.projectId, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode);
280
- } // create the data plane resource
281
-
282
-
283
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], apigeeXAgentValues.dataplaneConfig); // create data plane secret resource
222
+ }
284
223
 
224
+ // create the data plane resource
225
+ let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], apigeeXAgentValues.dataplaneConfig);
226
+ // create data plane secret resource
285
227
  try {
286
228
  await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(apigeeXAgentValues, dataplaneRes));
287
229
  } catch (error) {
288
230
  console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
289
-
290
231
  if (installConfig.centralConfig.ampcEnvInfo.isNew) {
291
232
  await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
292
233
  } else {
293
234
  await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
294
235
  }
295
-
296
236
  return;
297
- } // create discovery agent resource
298
-
237
+ }
299
238
 
239
+ // create discovery agent resource
300
240
  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, apigeeXAgentValues.frequencyDA, apigeeXAgentValues.queueDA);
301
-
302
241
  if (installConfig.switches.isTaEnabled) {
303
242
  // create traceability agent resource
304
243
  installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ta, _types.AgentTypes.ta, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Traceability Agent", dataplaneRes.name, apigeeXAgentValues.frequencyTA, false // APIGEE X TA is never triggered at install, as DA has to run prior
@@ -307,8 +246,7 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
307
246
 
308
247
  console.log(await generateOutput(installConfig));
309
248
  };
310
-
311
- const APIGEEXSaaSInstallMethods = {
249
+ const APIGEEXSaaSInstallMethods = exports.APIGEEXSaaSInstallMethods = {
312
250
  GetBundleType: askBundleType,
313
251
  GetDeploymentType: askConfigType,
314
252
  AskGatewayQuestions: gatewayConnectivity,
@@ -319,14 +257,13 @@ const APIGEEXSaaSInstallMethods = {
319
257
  [_types.AgentTypes.ta]: _types.AgentNames.APIGEEX_TA
320
258
  },
321
259
  GatewayDisplay: _types.GatewayTypes.APIGEEX_GATEWAY
322
- }; // These are the items that are not exported, but need to be for testing
260
+ };
323
261
 
324
- exports.APIGEEXSaaSInstallMethods = APIGEEXSaaSInstallMethods;
325
- const testables = {
262
+ // These are the items that are not exported, but need to be for testing
263
+ const testables = exports.testables = {
326
264
  SaasAgentValues,
327
265
  SaasAPIGEEXAgentValues,
328
266
  APIGEEXAuthType,
329
267
  SaasPrompts,
330
268
  ConfigFiles
331
- };
332
- exports.testables = testables;
269
+ };