@axway/axway-central-cli 2.17.0-rc.5 → 2.17.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 +28 -6
  2. package/dist/commands/apply/index.js +24 -9
  3. package/dist/commands/completion/index.js +9 -3
  4. package/dist/commands/config/common/index.js +11 -2
  5. package/dist/commands/config/index.js +7 -2
  6. package/dist/commands/config/list.js +6 -2
  7. package/dist/commands/config/set.js +31 -4
  8. package/dist/commands/config/unset.js +12 -2
  9. package/dist/commands/create/agentResource.js +32 -12
  10. package/dist/commands/create/environment.js +16 -6
  11. package/dist/commands/create/index.js +26 -9
  12. package/dist/commands/create/serviceAccount.js +6 -2
  13. package/dist/commands/delete/index.js +33 -15
  14. package/dist/commands/edit/environment.js +21 -6
  15. package/dist/commands/edit/index.js +8 -4
  16. package/dist/commands/get/index.js +44 -27
  17. package/dist/commands/install/agents.js +73 -44
  18. package/dist/commands/install/apigeexSaasAgents.js +98 -35
  19. package/dist/commands/install/awsAgents.js +139 -89
  20. package/dist/commands/install/awsSaasAgents.js +142 -50
  21. package/dist/commands/install/azureAgents.js +79 -39
  22. package/dist/commands/install/edgeAgents.js +110 -17
  23. package/dist/commands/install/helpers/creators.js +70 -17
  24. package/dist/commands/install/helpers/deleters.js +11 -2
  25. package/dist/commands/install/helpers/getters.js +30 -4
  26. package/dist/commands/install/helpers/index.js +48 -13
  27. package/dist/commands/install/helpers/inputs.js +98 -26
  28. package/dist/commands/install/helpers/regex.js +34 -29
  29. package/dist/commands/install/helpers/templates/awsTemplates.js +23 -6
  30. package/dist/commands/install/helpers/templates/azureTemplates.js +24 -5
  31. package/dist/commands/install/helpers/templates/edgeTemplates.js +38 -7
  32. package/dist/commands/install/helpers/templates/istioTemplates.js +16 -5
  33. package/dist/commands/install/index.js +10 -4
  34. package/dist/commands/install/istioAgents.js +117 -40
  35. package/dist/commands/install/platform.js +52 -20
  36. package/dist/commands/proxies/create.js +18 -2
  37. package/dist/commands/proxies/index.js +8 -4
  38. package/dist/commands/proxies/promote.js +21 -2
  39. package/dist/common/ApiServerClient.js +173 -64
  40. package/dist/common/CacheController.js +32 -11
  41. package/dist/common/CliConfigManager.js +27 -14
  42. package/dist/common/CompositeError.js +30 -6
  43. package/dist/common/CoreConfigController.js +40 -18
  44. package/dist/common/DefinitionsManager.js +76 -29
  45. package/dist/common/Kubectl.js +25 -2
  46. package/dist/common/PlatformClient.js +63 -19
  47. package/dist/common/Renderer.js +87 -25
  48. package/dist/common/TmpFile.js +28 -11
  49. package/dist/common/bashCommands.js +22 -3
  50. package/dist/common/basicPrompts.js +43 -8
  51. package/dist/common/dataService.js +50 -22
  52. package/dist/common/errorHandler.js +9 -0
  53. package/dist/common/resultsRenderers.js +42 -10
  54. package/dist/common/types.js +341 -116
  55. package/dist/common/utils.js +99 -37
  56. package/dist/main.js +2 -0
  57. package/package.json +2 -2
  58. package/dist/commands/install/gitHubSaasAgents.js +0 -283
@@ -4,35 +4,56 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.v7TAHelmOverrideTemplate = exports.v7TAEnvVarTemplate = exports.v7DAHelmOverrideTemplate = exports.v7DAEnvVarTemplate = exports.V7AgentValues = void 0;
7
+
7
8
  var _ = require("..");
9
+
8
10
  var _types = require("../../../../common/types");
9
- 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; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
- 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); }
11
+
12
+ 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; }
13
+
12
14
  /**
13
15
  * @description Values to provide to the v7 handlebars templates.
14
16
  */
15
17
  class V7AgentValues {
16
18
  constructor() {
17
19
  _defineProperty(this, "amplifyAgentCreds", void 0);
20
+
18
21
  _defineProperty(this, "amplifyAgentKeys", void 0);
22
+
19
23
  _defineProperty(this, "apiGatewayAuthPass", void 0);
24
+
20
25
  _defineProperty(this, "apiGatewayAuthUser", void 0);
26
+
21
27
  _defineProperty(this, "apiGatewayHost", void 0);
28
+
22
29
  _defineProperty(this, "apiGatewayPort", void 0);
30
+
23
31
  _defineProperty(this, "apiManagerAuthPass", void 0);
32
+
24
33
  _defineProperty(this, "apiManagerAuthUser", void 0);
34
+
25
35
  _defineProperty(this, "apiManagerHost", void 0);
36
+
26
37
  _defineProperty(this, "apiManagerPort", void 0);
38
+
27
39
  _defineProperty(this, "eventLogPath", void 0);
40
+
28
41
  _defineProperty(this, "eventLogPathTemplate", void 0);
42
+
29
43
  _defineProperty(this, "isGatewayOnly", void 0);
44
+
30
45
  _defineProperty(this, "isOpenTraffic", void 0);
46
+
31
47
  _defineProperty(this, "namespace", void 0);
48
+
32
49
  _defineProperty(this, "centralConfig", void 0);
50
+
33
51
  _defineProperty(this, "traceabilityConfig", void 0);
52
+
34
53
  _defineProperty(this, "daVersion", void 0);
54
+
35
55
  _defineProperty(this, "taVersion", void 0);
56
+
36
57
  this.amplifyAgentCreds = _.amplifyAgentsCredsSecret;
37
58
  this.amplifyAgentKeys = _.amplifyAgentsKeysSecret;
38
59
  this.apiGatewayAuthPass = '';
@@ -56,12 +77,15 @@ class V7AgentValues {
56
77
  this.daVersion = '';
57
78
  this.taVersion = '';
58
79
  }
59
- }
60
80
 
81
+ }
61
82
  /**
62
83
  * @description Generates the V7 TA env vars file.
63
84
  */
85
+
86
+
64
87
  exports.V7AgentValues = V7AgentValues;
88
+
65
89
  const v7TAEnvVarTemplate = () => {
66
90
  return `{{#unless isGatewayOnly}}
67
91
  # API Manager configs
@@ -135,11 +159,13 @@ LOG_OUTPUT=stdout
135
159
  LOG_FILE_PATH=logs
136
160
  `;
137
161
  };
138
-
139
162
  /**
140
163
  * @description Generates the V7 TA helm overrides.
141
164
  */
165
+
166
+
142
167
  exports.v7TAEnvVarTemplate = v7TAEnvVarTemplate;
168
+
143
169
  const v7TAHelmOverrideTemplate = () => {
144
170
  return `---
145
171
  replicaCount: 1
@@ -254,11 +280,13 @@ persistentVolumeClaimConfig:
254
280
  name: events-claim
255
281
  `;
256
282
  };
257
-
258
283
  /**
259
284
  * @description Generates the V7 DA env vars file.
260
285
  */
286
+
287
+
261
288
  exports.v7TAHelmOverrideTemplate = v7TAHelmOverrideTemplate;
289
+
262
290
  const v7DAEnvVarTemplate = () => {
263
291
  return `# API Manager configs
264
292
  APIMANAGER_AUTH_USERNAME={{apiManagerAuthUser}}
@@ -290,11 +318,13 @@ LOG_OUTPUT=stdout
290
318
  LOG_FILE_PATH=logs
291
319
  `;
292
320
  };
293
-
294
321
  /**
295
322
  * @description Generates the V7 DA helm overrides.
296
323
  */
324
+
325
+
297
326
  exports.v7DAEnvVarTemplate = v7DAEnvVarTemplate;
327
+
298
328
  const v7DAHelmOverrideTemplate = () => {
299
329
  return `---
300
330
  replicaCount: 1
@@ -372,4 +402,5 @@ resources: {}
372
402
  # memory: 128Mi
373
403
  `;
374
404
  };
405
+
375
406
  exports.v7DAHelmOverrideTemplate = v7DAHelmOverrideTemplate;
@@ -4,30 +4,38 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.istioInstallTemplate = exports.istioAgentsTemplate = exports.IstioValues = void 0;
7
+
7
8
  var _types = require("../../../../common/types");
8
- 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; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
- 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); }
9
+
10
+ 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; }
11
+
11
12
  /**
12
13
  * @description Values for installing the Istio Agents
13
14
  */
14
15
  class IstioValues {
15
16
  constructor() {
16
17
  _defineProperty(this, "istioAgentValues", void 0);
18
+
17
19
  _defineProperty(this, "istioInstallValues", void 0);
20
+
18
21
  _defineProperty(this, "centralConfig", void 0);
22
+
19
23
  _defineProperty(this, "traceabilityConfig", void 0);
24
+
20
25
  this.istioAgentValues = new _types.IstioAgentValues();
21
26
  this.istioInstallValues = new _types.IstioInstallValues();
22
27
  this.centralConfig = new _types.CentralAgentConfig();
23
28
  this.traceabilityConfig = new _types.TraceabilityConfig();
24
29
  }
25
- }
26
30
 
31
+ }
27
32
  /**
28
33
  * @description Generates the override file for the Amplify Istio Agents.
29
34
  */
35
+
36
+
30
37
  exports.IstioValues = IstioValues;
38
+
31
39
  const istioAgentsTemplate = () => {
32
40
  return `---
33
41
  global:
@@ -125,11 +133,13 @@ const istioAgentsTemplate = () => {
125
133
  list:
126
134
  enabled: {{istioAgentValues.demoSvcEnabled}}`;
127
135
  };
128
-
129
136
  /**
130
137
  * @description Generates the override file to install Istio with settings to connect to the Istio Traceability Agent.
131
138
  */
139
+
140
+
132
141
  exports.istioAgentsTemplate = istioAgentsTemplate;
142
+
133
143
  const istioInstallTemplate = () => {
134
144
  return `---
135
145
  apiVersion: install.istio.io/v1alpha1
@@ -201,4 +211,5 @@ spec:
201
211
  {{/if}}
202
212
  `;
203
213
  };
214
+
204
215
  exports.istioInstallTemplate = istioInstallTemplate;
@@ -4,11 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.install = void 0;
7
+
7
8
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
9
+
8
10
  var _types = require("../../common/types");
11
+
9
12
  var _agents = require("./agents");
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const install = exports.install = {
15
+
16
+ const install = {
12
17
  action({
13
18
  console
14
19
  }) {
@@ -19,6 +24,7 @@ To install agents in interactive mode:\t"axway central install agents"
19
24
  `);
20
25
  process.exit(1);
21
26
  },
27
+
22
28
  commands: {
23
29
  agents: _agents.agents
24
30
  },
@@ -30,7 +36,7 @@ To install agents in interactive mode:\t"axway central install agents"
30
36
  required: false,
31
37
  type: 'string'
32
38
  }],
33
- options: {
34
- ..._types.commonCmdArgsDescription
39
+ options: { ..._types.commonCmdArgsDescription
35
40
  }
36
- };
41
+ };
42
+ exports.install = install;
@@ -4,40 +4,64 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.testables = exports.setupKubernetes = exports.setupIstio = exports.istioSystemNs = exports.istioPrompts = exports.installPreprocess = exports.getCondorHost = exports.gatewayConnectivity = exports.gatewayCertSecret = exports.defaultLogFiles = exports.createIstioOverride = exports.createIstioGatewayCert = exports.createHybridOverride = exports.createEnvResources = exports.completeInstall = exports.askIstioSecret = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.amplifyAgentsCredsSecret = exports.ampcDemoNs = exports.IstioInstallMethods = exports.ConfigFiles = exports.AlsMode = void 0;
7
+
7
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
+
8
10
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
11
+
9
12
  var _bashCommands = require("../../common/bashCommands");
13
+
10
14
  var _basicPrompts = require("../../common/basicPrompts");
15
+
11
16
  var _Kubectl = require("../../common/Kubectl");
17
+
12
18
  var _types = require("../../common/types");
19
+
13
20
  var _utils = require("../../common/utils");
14
- var _helpers = _interopRequireWildcard(require("./helpers"));
15
- var helpers = _helpers;
21
+
22
+ var helpers = _interopRequireWildcard(require("./helpers"));
23
+
16
24
  var _inputs = require("./helpers/inputs");
25
+
17
26
  var _istioTemplates = require("./helpers/templates/istioTemplates");
18
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
27
+
28
+ 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); }
29
+
30
+ 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; }
31
+
20
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
+
21
34
  // @ts-ignore
22
35
  const {
23
36
  log
24
37
  } = (0, _snooplogg.default)('central: install: agents: istio:');
25
- const amplifyAgentsNs = exports.amplifyAgentsNs = 'amplify-agents';
26
- const gatewayCertSecret = exports.gatewayCertSecret = 'gateway-cert';
27
- const istioSystemNs = exports.istioSystemNs = 'istio-system';
28
- const ampcDemoNs = exports.ampcDemoNs = 'ampc-demo';
29
- const defaultLogFiles = exports.defaultLogFiles = '/group-*_instance-*.log';
30
- const amplifyAgentsCredsSecret = exports.amplifyAgentsCredsSecret = 'amplify-agents-credentials';
31
- let AlsMode = exports.AlsMode = /*#__PURE__*/function (AlsMode) {
38
+ const amplifyAgentsNs = 'amplify-agents';
39
+ exports.amplifyAgentsNs = amplifyAgentsNs;
40
+ const gatewayCertSecret = 'gateway-cert';
41
+ exports.gatewayCertSecret = gatewayCertSecret;
42
+ const istioSystemNs = 'istio-system';
43
+ exports.istioSystemNs = istioSystemNs;
44
+ const ampcDemoNs = 'ampc-demo';
45
+ exports.ampcDemoNs = ampcDemoNs;
46
+ const defaultLogFiles = '/group-*_instance-*.log';
47
+ exports.defaultLogFiles = defaultLogFiles;
48
+ const amplifyAgentsCredsSecret = 'amplify-agents-credentials';
49
+ exports.amplifyAgentsCredsSecret = amplifyAgentsCredsSecret;
50
+ let AlsMode; // ConfigFiles - all the config file that are used in the setup
51
+
52
+ exports.AlsMode = AlsMode;
53
+
54
+ (function (AlsMode) {
32
55
  AlsMode["Verbose"] = "verbose";
33
56
  AlsMode["Default"] = "default";
34
- return AlsMode;
35
- }({}); // ConfigFiles - all the config file that are used in the setup
36
- const ConfigFiles = exports.ConfigFiles = {
57
+ })(AlsMode || (exports.AlsMode = AlsMode = {}));
58
+
59
+ const ConfigFiles = {
37
60
  IstioOverrideFile: 'istio-override.yaml',
38
61
  HybridOverrideFile: 'hybrid-override.yaml'
39
62
  };
40
- const istioPrompts = exports.istioPrompts = {
63
+ exports.ConfigFiles = ConfigFiles;
64
+ const istioPrompts = {
41
65
  // istio
42
66
  enterProtocol: 'Enter the protocol to use for the ingress gateway',
43
67
  enterPort: 'Enter the Kubernetes cluster port',
@@ -54,17 +78,23 @@ const istioPrompts = exports.istioPrompts = {
54
78
  alsMode: 'Select Traceability Agent HTTP header publishing mode',
55
79
  demoService: 'Do you want to deploy the optional demo application?'
56
80
  };
81
+ exports.istioPrompts = istioPrompts;
82
+
57
83
  const askBundleType = async () => {
58
84
  return await (0, _basicPrompts.askList)({
59
85
  msg: helpers.agentMessages.selectAgentType,
60
86
  choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY, _types.BundleType.TRACEABILITY]
61
87
  });
62
88
  };
89
+
63
90
  exports.askBundleType = askBundleType;
91
+
64
92
  const askConfigType = async () => {
65
93
  return _types.AgentConfigTypes.DOCKERIZED;
66
94
  };
95
+
67
96
  exports.askConfigType = askConfigType;
97
+
68
98
  const gatewayConnectivity = async (installConfig, apiServerClient, defsManager) => {
69
99
  let istioValues = new _istioTemplates.IstioValues();
70
100
  console.log('\nCONNECTING A KUBERNETES CLUSTER TO AMPLIFY CENTRAL\n');
@@ -77,13 +107,14 @@ https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/m
77
107
  const {
78
108
  error
79
109
  } = await _Kubectl.kubectl.isInstalled();
110
+
80
111
  if (error) {
81
112
  throw new Error(`Kubectl is required to fill out the following prompts. It appears to be missing or misconfigured.\n${error}`);
82
113
  }
114
+
83
115
  const istioOverrides = await setupIstio(istioValues);
84
- installConfig.gatewayConfig = istioValues;
116
+ installConfig.gatewayConfig = istioValues; // Set up the following values from installConfig to be used in setupKubernetes
85
117
 
86
- // Set up the following values from installConfig to be used in setupKubernetes
87
118
  istioValues.istioAgentValues.alsEnabled = installConfig.switches.isTaEnabled;
88
119
  istioValues.istioAgentValues.discoveryEnabled = installConfig.switches.isDaEnabled;
89
120
  const hybridOverrides = await setupKubernetes(istioValues, apiServerClient, defsManager);
@@ -92,23 +123,27 @@ https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/m
92
123
  istioOverrides.enableAls = hybridOverrides.alsMode === AlsMode.Verbose;
93
124
  istioOverrides.enableTracing = hybridOverrides.alsEnabled;
94
125
  return istioValues;
95
- };
126
+ }; // Questions for the istio configuration
127
+
96
128
 
97
- // Questions for the istio configuration
98
129
  exports.gatewayConnectivity = gatewayConnectivity;
130
+
99
131
  const askUseExistingIstio = async () => (0, _basicPrompts.askList)({
100
132
  msg: istioPrompts.existingIstio,
101
133
  choices: _types.YesNoChoices
102
134
  });
135
+
103
136
  const askEnvoyFilterNamespace = async namespaces => (0, _basicPrompts.askList)({
104
137
  msg: istioPrompts.askEnvoyFilterNamespace,
105
138
  choices: namespaces.data
106
139
  });
140
+
107
141
  const askHost = async () => await (0, _basicPrompts.askInput)({
108
142
  msg: istioPrompts.enterDomainName,
109
- validate: (0, _basicPrompts.validateRegex)(_helpers.domainNameRegex, _helpers.invalidDomainName),
143
+ validate: (0, _basicPrompts.validateRegex)(helpers.domainNameRegex, helpers.invalidDomainName),
110
144
  allowEmptyInput: true
111
145
  });
146
+
112
147
  const askProtocol = async () => (0, _basicPrompts.askList)({
113
148
  msg: istioPrompts.enterProtocol,
114
149
  choices: [{
@@ -119,11 +154,13 @@ const askProtocol = async () => (0, _basicPrompts.askList)({
119
154
  value: _types.Protocol.HTTPS
120
155
  }]
121
156
  });
157
+
122
158
  const askPort = async protocol => await (0, _basicPrompts.askInput)({
123
159
  msg: istioPrompts.enterPort,
124
160
  type: 'number',
125
161
  defaultValue: protocol === _types.Protocol.HTTP ? 8080 : 443
126
162
  });
163
+
127
164
  const askCertificateOption = async () => (0, _basicPrompts.askList)({
128
165
  msg: istioPrompts.generateCertPrompt,
129
166
  choices: [{
@@ -134,16 +171,18 @@ const askCertificateOption = async () => (0, _basicPrompts.askList)({
134
171
  value: _types.Certificate.PROVIDE
135
172
  }]
136
173
  });
174
+
137
175
  const askIstioProfile = async () => (0, _basicPrompts.askList)({
138
176
  msg: istioPrompts.istioProfile,
139
177
  choices: _types.IstioProfileChoices
140
- });
178
+ }); //Setup Overrides
179
+
141
180
 
142
- //Setup Overrides
143
181
  const setupIstio = async istioValues => {
144
182
  let istioInstallValues = istioValues.istioInstallValues;
145
183
  console.log(_chalk.default.gray('If Istio is not yet installed, select No. If Istio is already running select Yes.\n'));
146
184
  const useExistingIstio = await askUseExistingIstio();
185
+
147
186
  if (useExistingIstio === _types.YesNo.Yes) {
148
187
  const namespaces = await _Kubectl.kubectl.get('namespaces');
149
188
  if (namespaces.error) throw new Error(namespaces.error);
@@ -152,40 +191,48 @@ const setupIstio = async istioValues => {
152
191
  istioInstallValues.isNewInstall = false;
153
192
  return istioInstallValues;
154
193
  }
194
+
155
195
  istioInstallValues.profile = await askIstioProfile();
156
196
  console.log(_chalk.default.gray('\nFor a Kubernetes cluster exposing HTTPS endpoints, you must own or be able to configure a certificate for the correspoinding fully qualified domain name\n'));
157
197
  istioInstallValues.host = (await askHost()).toLowerCase();
198
+
158
199
  if (istioInstallValues.host) {
159
200
  istioInstallValues.protocol = await askProtocol();
160
201
  istioInstallValues.port = await askPort(istioInstallValues.protocol);
202
+
161
203
  if (istioInstallValues.protocol === _types.Protocol.HTTPS) {
162
204
  istioInstallValues.certSecretName = await askIstioSecret(istioPrompts.enterIstioSecret, istioSystemNs, gatewayCertSecret);
163
205
  istioInstallValues.certificateOption = await askCertificateOption();
164
206
  }
165
207
  }
208
+
166
209
  istioInstallValues.targetPort = istioInstallValues.protocol === _types.Protocol.HTTP ? 8080 : 8443;
167
210
  return istioValues.istioInstallValues;
168
211
  };
212
+
169
213
  exports.setupIstio = setupIstio;
214
+
170
215
  const askIstioSecret = async (msg, namespace, defaultSecretName) => {
171
- const allSecrets = await _Kubectl.kubectl.get('secrets', `-n ${namespace}`);
172
- // No resources errors are ok. Throw an error for anything else.
216
+ const allSecrets = await _Kubectl.kubectl.get('secrets', `-n ${namespace}`); // No resources errors are ok. Throw an error for anything else.
217
+
173
218
  if (allSecrets.error && !allSecrets.error.includes('K8S secrets: No resources found')) throw Error(allSecrets.error);
174
219
  return (0, _inputs.askForSecretName)(msg, defaultSecretName, allSecrets.data);
175
220
  };
221
+
176
222
  exports.askIstioSecret = askIstioSecret;
223
+
177
224
  const completeIstio = async istioOverrides => {
178
225
  if (istioOverrides.protocol === _types.Protocol.HTTPS) {
179
226
  if (istioOverrides.isNewInstall) {
180
227
  await _Kubectl.kubectl.create('ns', istioSystemNs);
181
228
  }
229
+
182
230
  await createIstioGatewayCert(istioOverrides.envoyFilterNamespace, istioOverrides);
183
231
  }
184
- };
232
+ }; // Above this line is Istio. Below is Kubernetes
233
+ // Questions for the kubernetes configuration
185
234
 
186
- // Above this line is Istio. Below is Kubernetes
187
235
 
188
- // Questions for the kubernetes configuration
189
236
  const askALSMode = async () => {
190
237
  return (0, _basicPrompts.askList)({
191
238
  msg: istioPrompts.alsMode,
@@ -198,6 +245,7 @@ const askALSMode = async () => {
198
245
  }]
199
246
  });
200
247
  };
248
+
201
249
  const askVsNamespacePrompt = async () => {
202
250
  const namespaces = await _Kubectl.kubectl.get('ns');
203
251
  if (namespaces.error) throw Error(namespaces.error);
@@ -206,41 +254,49 @@ const askVsNamespacePrompt = async () => {
206
254
  choices: namespaces.data
207
255
  });
208
256
  };
257
+
209
258
  const askEnableDemoSvc = async () => {
210
259
  const res = (0, _basicPrompts.askList)({
211
260
  msg: istioPrompts.demoService,
212
261
  choices: _types.YesNoChoices
213
262
  });
214
263
  return (await res) === _types.YesNo.Yes ? true : false;
215
- };
264
+ }; //Setup Overrides
265
+
216
266
 
217
- //Setup Overrides
218
267
  const setupKubernetes = async (istioValues, apiServerClient, defsManager) => {
219
268
  let istioAgentValues = istioValues.istioAgentValues;
220
269
  console.log(_chalk.default.gray(`\nThere are several steps to prepare a Kubernetes cluster for the Amplify Istio Agents.\nThe following questions collect the namespace and secret to use for the Istio gateway.\n`));
270
+
221
271
  if (istioAgentValues.alsEnabled) {
222
272
  console.log(_chalk.default.gray(`\nThe Istio Traceability Agent can log a minimal set of HTTP headers needed for transaction publishing (default) or it can capture all headers (verbose).\n`));
223
273
  istioAgentValues.alsMode = await askALSMode();
224
274
  }
275
+
225
276
  if (istioAgentValues.discoveryEnabled) {
226
277
  const ns = await askVsNamespacePrompt();
227
278
  istioAgentValues.discoveryNamespaces = [ns];
228
279
  }
280
+
229
281
  istioAgentValues.namespace = await (0, _inputs.askNamespace)(istioPrompts.meshAgentNamespace, amplifyAgentsNs);
230
282
  istioAgentValues.demoSvcEnabled = await askEnableDemoSvc();
283
+
231
284
  if (istioAgentValues.discoveryEnabled && istioAgentValues.demoSvcEnabled && !istioAgentValues.discoveryNamespaces.includes(ampcDemoNs)) {
232
285
  istioAgentValues.discoveryNamespaces.push(ampcDemoNs);
233
- }
286
+ } // set keySecretName
287
+
234
288
 
235
- // set keySecretName
236
289
  istioAgentValues.keysSecretName = helpers.amplifyAgentsKeysSecret;
237
- istioAgentValues.clusterName = await (0, _helpers.askK8sClusterName)(apiServerClient, defsManager);
290
+ istioAgentValues.clusterName = await (0, helpers.askK8sClusterName)(apiServerClient, defsManager);
238
291
  return istioAgentValues;
239
292
  };
293
+
240
294
  exports.setupKubernetes = setupKubernetes;
295
+
241
296
  const createIstioGatewayCert = async (namespace, istioOverrides) => {
242
297
  let privateKey = '';
243
298
  let cert = '';
299
+
244
300
  if (istioOverrides.certificateOption === _types.Certificate.GENERATE) {
245
301
  ({
246
302
  cert,
@@ -249,12 +305,13 @@ const createIstioGatewayCert = async (namespace, istioOverrides) => {
249
305
  console.log(`Created ${istioOverrides.certSecretName}.crt and ${istioOverrides.certSecretName}.key in ${process.cwd()}`);
250
306
  } else {
251
307
  privateKey = await (0, _basicPrompts.askInput)({
252
- msg: _helpers.enterPublicKeyPath
308
+ msg: helpers.enterPublicKeyPath
253
309
  });
254
310
  cert = await (0, _basicPrompts.askInput)({
255
311
  msg: istioPrompts.enterCertPath
256
312
  });
257
313
  }
314
+
258
315
  const {
259
316
  data,
260
317
  error
@@ -262,9 +319,12 @@ const createIstioGatewayCert = async (namespace, istioOverrides) => {
262
319
  if (error) throw new Error(error);
263
320
  console.log(`Created ${data[0]} in the ${namespace} namespace.`);
264
321
  };
322
+
265
323
  exports.createIstioGatewayCert = createIstioGatewayCert;
324
+
266
325
  const getCondorHost = (region, env, apicDeployment) => {
267
326
  var _hosts$region, _hosts$region$env;
327
+
268
328
  const hosts = {
269
329
  [_types.Regions.US]: {
270
330
  [_types.Platforms.prod]: {
@@ -295,23 +355,30 @@ const getCondorHost = (region, env, apicDeployment) => {
295
355
  };
296
356
  return ((_hosts$region = hosts[region]) === null || _hosts$region === void 0 ? void 0 : (_hosts$region$env = _hosts$region[env]) === null || _hosts$region$env === void 0 ? void 0 : _hosts$region$env[apicDeployment]) || _types.IngestionHosts.US;
297
357
  };
358
+
298
359
  exports.getCondorHost = getCondorHost;
360
+
299
361
  const createIstioOverride = overrides => {
300
362
  const overrideFileName = ConfigFiles.IstioOverrideFile;
301
363
  (0, _utils.writeTemplates)(overrideFileName, overrides, helpers.istioInstallTemplate);
302
364
  console.log(`\nIstio override file has been placed at ${process.cwd()}/${overrideFileName}`);
365
+
303
366
  if (overrides.istioInstallValues.isNewInstall) {
304
367
  console.log('To complete the istio installation run the following command:', _chalk.default.cyan(`\n istioctl install --set profile=${overrides.istioInstallValues.profile} -f ${overrideFileName}\n`));
305
368
  } else {
306
369
  console.log(_chalk.default.cyan(` Please merge the generated ${overrideFileName} file with your Istio configuration to allow the Traceability Agent to function.\n`));
307
370
  }
308
371
  };
372
+
309
373
  exports.createIstioOverride = createIstioOverride;
374
+
310
375
  const createEnvResources = async (client, defs, clusterName) => {
311
376
  // Create the mesh K8SCluster resource
312
377
  await helpers.createByResourceType(client, defs, clusterName, 'K8SCluster', 'k8sc', {}, '');
313
378
  };
379
+
314
380
  exports.createEnvResources = createEnvResources;
381
+
315
382
  const createHybridOverride = overrides => {
316
383
  const overrideFileName = ConfigFiles.HybridOverrideFile;
317
384
  (0, _utils.writeTemplates)(overrideFileName, overrides, helpers.istioAgentsTemplate);
@@ -319,47 +386,55 @@ const createHybridOverride = overrides => {
319
386
  const installCmd = `helm upgrade --install --namespace ${overrides.istioAgentValues.namespace.name} ampc-hybrid axway/ampc-hybrid -f ${overrideFileName}`;
320
387
  console.log('To complete the Istio agent installation run the following commands:', _chalk.default.cyan('\n helm repo add axway https://charts.axway.com/charts'), _chalk.default.cyan(`\n helm repo update\n ${installCmd}`));
321
388
  };
389
+
322
390
  exports.createHybridOverride = createHybridOverride;
391
+
323
392
  const installPreprocess = async installConfig => {
324
393
  // name of the service account, and if it is new or not
325
-
326
394
  if (!installConfig.centralConfig.ampcDosaInfo.isNew) {
327
395
  [installConfig.centralConfig.dosaAccount.publicKey, installConfig.centralConfig.dosaAccount.privateKey] = await helpers.askPublicAndPrivateKeysPath();
328
396
  } else {
329
397
  console.log(_chalk.default.yellow(`The secret will be created with the same "private_key.pem" and "public_key.pem" that will be auto generated to create the Service Account, following the completion of these prompts.`));
330
398
  }
399
+
331
400
  return installConfig;
332
401
  };
402
+
333
403
  exports.installPreprocess = installPreprocess;
404
+
334
405
  const completeInstall = async (installConfig, apiServerClient, defsManager) => {
335
406
  // Contents of completeKubernetes moved here.
407
+ const istioValues = installConfig.gatewayConfig; // Add final settings to IstioAgentsValues
336
408
 
337
- const istioValues = installConfig.gatewayConfig;
338
-
339
- // Add final settings to IstioAgentsValues
340
409
  istioValues.centralConfig = installConfig.centralConfig;
341
410
  istioValues.traceabilityConfig = installConfig.traceabilityConfig;
342
411
  await completeIstio(istioValues.istioInstallValues);
412
+
343
413
  if (istioValues.istioAgentValues.namespace.isNew) {
344
414
  await helpers.createNamespace(istioValues.istioAgentValues.namespace.name);
345
415
  }
416
+
346
417
  await helpers.createSecret(istioValues.istioAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, async () => {
347
418
  if (installConfig.centralConfig.ampcDosaInfo.isNew) {
348
419
  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.`));
349
420
  }
421
+
350
422
  await helpers.createAmplifyAgentKeysSecret(istioValues.istioAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, 'publicKey', istioValues.centralConfig.dosaAccount.publicKey, 'privateKey', istioValues.centralConfig.dosaAccount.privateKey);
351
423
  });
424
+
352
425
  if (installConfig.switches.isDaEnabled) {
353
426
  await createEnvResources(apiServerClient, defsManager, istioValues.istioAgentValues.clusterName);
354
427
  }
428
+
355
429
  console.log('Generating the configuration file(s)...');
356
430
  createIstioOverride(istioValues);
357
431
  createHybridOverride(istioValues);
358
432
  console.log('Configuration file(s) have been successfully created.\n');
359
433
  console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.ISTIO}`));
360
434
  };
435
+
361
436
  exports.completeInstall = completeInstall;
362
- const IstioInstallMethods = exports.IstioInstallMethods = {
437
+ const IstioInstallMethods = {
363
438
  GetBundleType: askBundleType,
364
439
  GetDeploymentType: askConfigType,
365
440
  AskGatewayQuestions: gatewayConnectivity,
@@ -368,9 +443,11 @@ const IstioInstallMethods = exports.IstioInstallMethods = {
368
443
  ConfigFiles: Object.values(ConfigFiles),
369
444
  GatewayDisplay: _types.GatewayTypes.ISTIO
370
445
  };
371
- const testables = exports.testables = {
446
+ exports.IstioInstallMethods = IstioInstallMethods;
447
+ const testables = {
372
448
  istioPrompts,
373
449
  ConfigFiles,
374
450
  defaultLogFiles,
375
451
  amplifyAgentsCredsSecret
376
- };
452
+ };
453
+ exports.testables = testables;