@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,57 +4,42 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getListByResource = exports.getLatestAgentVersion = exports.getIngestionHost = exports.getEnvironmentId = exports.getCurrentUserOrgId = void 0;
7
-
8
7
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
-
10
8
  var _CoreConfigController = require("../../../common/CoreConfigController");
11
-
12
9
  var _dataService = require("../../../common/dataService");
13
-
14
10
  var _types = require("../../../common/types");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  const {
19
13
  log
20
14
  } = (0, _snooplogg.default)('central: install: agents: helpers');
21
-
22
15
  const getListByResource = async input => {
23
16
  // NOTE: only a first found set is used
24
17
  const defs = input.defsManager.findDefsByWord(input.resourceShortName);
25
-
26
18
  if (!defs) {
27
19
  throw Error(`the server doesn't have a resource type "${input.resourceType}"`);
28
20
  }
29
-
30
21
  return input.client.getResourcesList({
31
22
  resourceDef: defs[0].resource,
32
23
  scopeDef: defs[0].scope ? defs[0].scope : undefined,
33
24
  scopeName: input.scopeName,
34
25
  query: input.query
35
26
  });
36
- }; // Note: forcing it to use apicentral client id
37
-
27
+ };
38
28
 
29
+ // Note: forcing it to use apicentral client id
39
30
  exports.getListByResource = getListByResource;
40
-
41
31
  const getCurrentUserOrgId = async () => {
42
32
  const authData = await new _CoreConfigController.CoreConfigController().getAuthInfo();
43
33
  if (!authData.orgId) throw Error(`Can't find org ID`);
44
34
  return authData.orgId;
45
35
  };
46
-
47
36
  exports.getCurrentUserOrgId = getCurrentUserOrgId;
48
-
49
37
  const getEnvironmentId = async (client, defsManager, environmentName, scopeName) => {
50
38
  var _resource$data;
51
-
52
39
  const defs = defsManager.findDefsByWord('env');
53
-
54
40
  if (!defs) {
55
41
  throw Error(`the server doesn't have a resource type "Environment"`);
56
42
  }
57
-
58
43
  const resource = await client.getResourceByName({
59
44
  resourceDef: defs[0].resource,
60
45
  resourceName: environmentName,
@@ -63,9 +48,7 @@ const getEnvironmentId = async (client, defsManager, environmentName, scopeName)
63
48
  });
64
49
  return (_resource$data = resource.data) !== null && _resource$data !== void 0 && _resource$data.metadata ? resource.data.metadata.id || '' : '';
65
50
  };
66
-
67
51
  exports.getEnvironmentId = getEnvironmentId;
68
-
69
52
  const getIngestionHost = (region, env, apicDeployment, protocol = _types.IngestionProtocol.Lumberjack) => {
70
53
  const hosts = {
71
54
  [_types.IngestionProtocol.Lumberjack]: {
@@ -125,9 +108,7 @@ const getIngestionHost = (region, env, apicDeployment, protocol = _types.Ingesti
125
108
  };
126
109
  return hosts[protocol][region][env][apicDeployment] || _types.IngestionHosts.US;
127
110
  };
128
-
129
111
  exports.getIngestionHost = getIngestionHost;
130
-
131
112
  const getLatestAgentVersion = async agent => {
132
113
  try {
133
114
  const service = await (0, _dataService.dataService)({
@@ -138,35 +119,29 @@ const getLatestAgentVersion = async agent => {
138
119
  // docker api requires auth, even if its just anonymous
139
120
  Authorization: `Basic ${Buffer.from('anonymous:').toString('base64')}`
140
121
  }, true);
141
-
142
122
  if (response.tags.length === 0) {
143
123
  return 'latest';
144
124
  }
145
-
146
125
  const latestVersion = response.tags.reduce((prev, current) => {
147
126
  // skip any tags that are latest
148
127
  if (prev === 'latest') {
149
128
  return current;
150
129
  } else if (current === 'latest') {
151
130
  return prev;
152
- } // find the largest tag
153
-
131
+ }
154
132
 
133
+ // find the largest tag
155
134
  const [pMajor, pMinor, pPatch] = prev.split('.').map(Number);
156
135
  const [cMajor, cMinor, cPatch] = current.split('.').map(Number);
157
-
158
136
  if (cMajor > pMajor) {
159
137
  return current;
160
138
  }
161
-
162
139
  if (cMajor == pMajor && cMinor > pMinor) {
163
140
  return current;
164
141
  }
165
-
166
142
  if (cMajor == pMajor && cMinor == pMinor && cPatch > pPatch) {
167
143
  return current;
168
144
  }
169
-
170
145
  return prev;
171
146
  });
172
147
  log(`Latest Version (${agent}): ${latestVersion}`);
@@ -177,5 +152,4 @@ const getLatestAgentVersion = async agent => {
177
152
  return 'latest';
178
153
  }
179
154
  };
180
-
181
155
  exports.getLatestAgentVersion = getLatestAgentVersion;
@@ -17,15 +17,10 @@ var _exportNames = {
17
17
  agentsDocsUrl: true
18
18
  };
19
19
  exports.unzip = exports.streamPipeline = exports.pwdWin = exports.pwd = exports.invalidValueExampleErrMsg = exports.eolCharWin = exports.eolChar = exports.configFiles = exports.amplifyAgentsKeysSecret = exports.amplifyAgentsCredsSecret = exports.agentsDocsUrl = void 0;
20
-
21
20
  var _extractZip = _interopRequireDefault(require("extract-zip"));
22
-
23
21
  var _stream = _interopRequireDefault(require("stream"));
24
-
25
22
  var _util = _interopRequireDefault(require("util"));
26
-
27
23
  var _deleters = require("./deleters");
28
-
29
24
  Object.keys(_deleters).forEach(function (key) {
30
25
  if (key === "default" || key === "__esModule") return;
31
26
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -37,9 +32,7 @@ Object.keys(_deleters).forEach(function (key) {
37
32
  }
38
33
  });
39
34
  });
40
-
41
35
  var _creators = require("./creators");
42
-
43
36
  Object.keys(_creators).forEach(function (key) {
44
37
  if (key === "default" || key === "__esModule") return;
45
38
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -51,9 +44,7 @@ Object.keys(_creators).forEach(function (key) {
51
44
  }
52
45
  });
53
46
  });
54
-
55
47
  var _getters = require("./getters");
56
-
57
48
  Object.keys(_getters).forEach(function (key) {
58
49
  if (key === "default" || key === "__esModule") return;
59
50
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -65,9 +56,7 @@ Object.keys(_getters).forEach(function (key) {
65
56
  }
66
57
  });
67
58
  });
68
-
69
59
  var _inputs = require("./inputs");
70
-
71
60
  Object.keys(_inputs).forEach(function (key) {
72
61
  if (key === "default" || key === "__esModule") return;
73
62
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -79,9 +68,7 @@ Object.keys(_inputs).forEach(function (key) {
79
68
  }
80
69
  });
81
70
  });
82
-
83
71
  var _regex = require("./regex");
84
-
85
72
  Object.keys(_regex).forEach(function (key) {
86
73
  if (key === "default" || key === "__esModule") return;
87
74
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -93,9 +80,7 @@ Object.keys(_regex).forEach(function (key) {
93
80
  }
94
81
  });
95
82
  });
96
-
97
83
  var _awsTemplates = require("./templates/awsTemplates");
98
-
99
84
  Object.keys(_awsTemplates).forEach(function (key) {
100
85
  if (key === "default" || key === "__esModule") return;
101
86
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -107,9 +92,7 @@ Object.keys(_awsTemplates).forEach(function (key) {
107
92
  }
108
93
  });
109
94
  });
110
-
111
95
  var _azureTemplates = require("./templates/azureTemplates");
112
-
113
96
  Object.keys(_azureTemplates).forEach(function (key) {
114
97
  if (key === "default" || key === "__esModule") return;
115
98
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -121,9 +104,7 @@ Object.keys(_azureTemplates).forEach(function (key) {
121
104
  }
122
105
  });
123
106
  });
124
-
125
107
  var _edgeTemplates = require("./templates/edgeTemplates");
126
-
127
108
  Object.keys(_edgeTemplates).forEach(function (key) {
128
109
  if (key === "default" || key === "__esModule") return;
129
110
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -135,9 +116,7 @@ Object.keys(_edgeTemplates).forEach(function (key) {
135
116
  }
136
117
  });
137
118
  });
138
-
139
119
  var _istioTemplates = require("./templates/istioTemplates");
140
-
141
120
  Object.keys(_istioTemplates).forEach(function (key) {
142
121
  if (key === "default" || key === "__esModule") return;
143
122
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -149,49 +128,35 @@ Object.keys(_istioTemplates).forEach(function (key) {
149
128
  }
150
129
  });
151
130
  });
152
-
153
131
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
154
-
155
- const streamPipeline = _util.default.promisify(_stream.default.pipeline);
156
-
157
- exports.streamPipeline = streamPipeline;
158
-
132
+ const streamPipeline = exports.streamPipeline = _util.default.promisify(_stream.default.pipeline);
159
133
  const unzip = async filePath => {
160
134
  await (0, _extractZip.default)(filePath, {
161
135
  dir: process.cwd()
162
136
  });
163
137
  };
164
-
165
138
  exports.unzip = unzip;
166
-
167
139
  const invalidValueExampleErrMsg = (resourceType, example) => {
168
140
  return `Invalid ${resourceType} entered. ${resourceType} must be in the form of ${example}`;
169
141
  };
170
-
171
142
  exports.invalidValueExampleErrMsg = invalidValueExampleErrMsg;
172
- const eolChar = '\\';
173
- exports.eolChar = eolChar;
174
- const eolCharWin = '^';
175
- exports.eolCharWin = eolCharWin;
176
- const pwd = '"$(pwd)"';
177
- exports.pwd = pwd;
178
- const pwdWin = '"%cd%"';
179
- exports.pwdWin = pwdWin;
180
- const amplifyAgentsKeysSecret = 'amplify-agents-keys';
181
- exports.amplifyAgentsKeysSecret = amplifyAgentsKeysSecret;
182
- const amplifyAgentsCredsSecret = 'amplify-agents-credentials'; // configFiles - the agent config file names
183
-
184
- exports.amplifyAgentsCredsSecret = amplifyAgentsCredsSecret;
185
- const configFiles = {
143
+ const eolChar = exports.eolChar = '\\';
144
+ const eolCharWin = exports.eolCharWin = '^';
145
+ const pwd = exports.pwd = '"$(pwd)"';
146
+ const pwdWin = exports.pwdWin = '"%cd%"';
147
+ const amplifyAgentsKeysSecret = exports.amplifyAgentsKeysSecret = 'amplify-agents-keys';
148
+ const amplifyAgentsCredsSecret = exports.amplifyAgentsCredsSecret = 'amplify-agents-credentials';
149
+
150
+ // configFiles - the agent config file names
151
+ const configFiles = exports.configFiles = {
186
152
  DA_ENV_VARS: 'da_env_vars.env',
187
153
  TA_ENV_VARS: 'ta_env_vars.env'
188
154
  };
189
- exports.configFiles = configFiles;
190
- const agentsDocsUrl = {
155
+ const agentsDocsUrl = exports.agentsDocsUrl = {
191
156
  V7: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/index.html',
192
157
  AWS: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_aws_gateway/index.html',
193
158
  AZURE: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_azure_gateway/index.html',
194
159
  ISTIO: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/mesh_management/index.html'
195
- }; // export * from './updaters';
160
+ };
196
161
 
197
- exports.agentsDocsUrl = agentsDocsUrl;
162
+ // export * from './updaters';
@@ -4,27 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.transactionLoggingMessages = exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = void 0;
7
-
8
7
  var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
8
  var _inquirer = _interopRequireDefault(require("inquirer"));
11
-
12
9
  var _basicPrompts = require("../../../common/basicPrompts");
13
-
14
10
  var _Kubectl = require("../../../common/Kubectl");
15
-
16
11
  var _PlatformClient = require("../../../common/PlatformClient");
17
-
18
12
  var _types = require("../../../common/types");
19
-
20
13
  var _getters = require("./getters");
21
-
22
14
  var _regex = require("./regex");
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
16
  const cliNowString = `cli-${Date.now()}`;
27
- const envMessages = {
17
+ const envMessages = exports.envMessages = {
28
18
  createNewEnvironment: 'Create a new environment',
29
19
  enterEnvironmentName: 'Enter a new environment name',
30
20
  isProduction: 'Is the environment used for production purpose?',
@@ -33,22 +23,19 @@ const envMessages = {
33
23
  environmentAlreadyExists: 'Environment already exists. Please enter a new name.',
34
24
  selectTeam: 'Select a team'
35
25
  };
36
- exports.envMessages = envMessages;
37
- const k8sClusterMessages = {
26
+ const k8sClusterMessages = exports.k8sClusterMessages = {
38
27
  enterK8sClusterName: 'Enter a unique k8s cluster name',
39
28
  getK8sClustersError: 'Get k8sCluster error.',
40
29
  k8sClusterAlreadyExists: 'k8sCluster already exists. Please enter a new name.'
41
30
  };
42
- exports.k8sClusterMessages = k8sClusterMessages;
43
- const agentMessages = {
31
+ const agentMessages = exports.agentMessages = {
44
32
  enterDiscoveryAgentName: 'Enter a new discovery agent name',
45
33
  enterTraceabilityAgentName: 'Enter a new traceability agent name',
46
34
  getAgentsError: 'Error getting agents.',
47
35
  agentAlreadyExists: 'Agent already exists. Please enter a new name.',
48
36
  selectAgentType: 'Select the type of agent(s) you want to install'
49
37
  };
50
- exports.agentMessages = agentMessages;
51
- const transactionLoggingMessages = {
38
+ const transactionLoggingMessages = exports.transactionLoggingMessages = {
52
39
  askToEnableLogging: 'Would you like to enable transaction logging?',
53
40
  transactionLoggingInfoMsg: 'Transaction logging is optional and not required for usage and metrics logging.\nTurning on transaction logging can have an impact on performance.',
54
41
  enterSamplingPercentage: 'What sampling rate would you like to use? (1-100)',
@@ -56,30 +43,17 @@ const transactionLoggingMessages = {
56
43
  askReportAllErrors: 'Would you like to report all errors?',
57
44
  reportAllErrorsMsg: 'The agents can take out the error transactions from the sampling rate.'
58
45
  };
59
- exports.transactionLoggingMessages = transactionLoggingMessages;
60
- const namespaceAlreadyExists = 'Namespace already exists. Please enter a new name.';
61
- exports.namespaceAlreadyExists = namespaceAlreadyExists;
62
- const secretAlreadyExists = 'Secret already exists. Please enter a new name.';
63
- exports.secretAlreadyExists = secretAlreadyExists;
64
- const enterNamespaceName = 'Enter a new namespace name';
65
- exports.enterNamespaceName = enterNamespaceName;
66
- const selectServiceAccount = 'Select a service account';
67
- exports.selectServiceAccount = selectServiceAccount;
68
- const enterServiceAccountName = 'Enter a new service account name';
69
- exports.enterServiceAccountName = enterServiceAccountName;
70
- const enterPublicKeyPath = 'Enter the file path to the public key';
71
- exports.enterPublicKeyPath = enterPublicKeyPath;
72
- const enterPrivateKeyPath = 'Enter the file path to the private key';
73
- exports.enterPrivateKeyPath = enterPrivateKeyPath;
74
- const selectIngestionProtocol = 'Select Traceability protocol';
75
- exports.selectIngestionProtocol = selectIngestionProtocol;
76
- const serviceAccountNameAlreadyExists = 'Service account already exists. Please enter a new name.';
77
- exports.serviceAccountNameAlreadyExists = serviceAccountNameAlreadyExists;
78
- const selectAWSRegion = 'Select an AWS Region';
79
- exports.selectAWSRegion = selectAWSRegion;
80
- const enterAWSRegion = 'Enter an AWS Region';
81
- exports.enterAWSRegion = enterAWSRegion;
82
-
46
+ const namespaceAlreadyExists = exports.namespaceAlreadyExists = 'Namespace already exists. Please enter a new name.';
47
+ const secretAlreadyExists = exports.secretAlreadyExists = 'Secret already exists. Please enter a new name.';
48
+ const enterNamespaceName = exports.enterNamespaceName = 'Enter a new namespace name';
49
+ const selectServiceAccount = exports.selectServiceAccount = 'Select a service account';
50
+ const enterServiceAccountName = exports.enterServiceAccountName = 'Enter a new service account name';
51
+ const enterPublicKeyPath = exports.enterPublicKeyPath = 'Enter the file path to the public key';
52
+ const enterPrivateKeyPath = exports.enterPrivateKeyPath = 'Enter the file path to the private key';
53
+ const selectIngestionProtocol = exports.selectIngestionProtocol = 'Select Traceability protocol';
54
+ const serviceAccountNameAlreadyExists = exports.serviceAccountNameAlreadyExists = 'Service account already exists. Please enter a new name.';
55
+ const selectAWSRegion = exports.selectAWSRegion = 'Select an AWS Region';
56
+ const enterAWSRegion = exports.enterAWSRegion = 'Enter an AWS Region';
83
57
  const askAWSRegion = async (region = '') => {
84
58
  let regions = Object.values(_types.AWSRegions).map(str => ({
85
59
  name: str,
@@ -93,7 +67,6 @@ const askAWSRegion = async (region = '') => {
93
67
  value: 'CREATE_NEW'
94
68
  }, ...regions]
95
69
  });
96
-
97
70
  if (answer === 'CREATE_NEW') {
98
71
  return await (0, _basicPrompts.askInput)({
99
72
  msg: enterAWSRegion
@@ -102,9 +75,7 @@ const askAWSRegion = async (region = '') => {
102
75
  return answer;
103
76
  }
104
77
  };
105
-
106
78
  exports.askAWSRegion = askAWSRegion;
107
-
108
79
  const askServiceAccountName = async serviceAccountNames => {
109
80
  console.warn(_chalk.default.yellow(`WARNING: Creating a new service account will overwrite any existing "private_key.pem" and "public_key.pem" files in this directory`));
110
81
  const name = await (0, _basicPrompts.askInput)({
@@ -114,14 +85,13 @@ const askServiceAccountName = async serviceAccountNames => {
114
85
  });
115
86
  return name;
116
87
  };
117
-
118
88
  exports.askServiceAccountName = askServiceAccountName;
119
-
120
89
  const askDosaClientId = async (client, showWarning = true) => {
121
90
  // Fetch all existing service accounts.
122
91
  const serviceAccounts = await client.getServiceAccounts(_PlatformClient.PlatformServiceAccountRole.ApiCentralAdmin);
123
- const serviceAccountNames = serviceAccounts.map(nextAccount => nextAccount.name); // Ask user to select an existing service account or create a new one.
92
+ const serviceAccountNames = serviceAccounts.map(nextAccount => nextAccount.name);
124
93
 
94
+ // Ask user to select an existing service account or create a new one.
125
95
  const selectedName = await (0, _basicPrompts.askList)({
126
96
  msg: selectServiceAccount,
127
97
  choices: [{
@@ -129,7 +99,6 @@ const askDosaClientId = async (client, showWarning = true) => {
129
99
  value: 'CREATE_NEW'
130
100
  }, new _inquirer.default.Separator(), ...serviceAccountNames, new _inquirer.default.Separator()]
131
101
  });
132
-
133
102
  if (selectedName === 'CREATE_NEW') {
134
103
  // We're going to create a new service account. Ask for a unique name. (We'll create it later.)
135
104
  const name = await askServiceAccountName(serviceAccountNames);
@@ -142,9 +111,9 @@ const askDosaClientId = async (client, showWarning = true) => {
142
111
  // We're using an existing service account. Notify user to make its keys available to the agents.
143
112
  if (showWarning) {
144
113
  console.log(_chalk.default.yellow('Please make sure your "private_key.pem" and "public_key.pem" files for the selected service account are in this installation folder.'));
145
- } // Fetch selected service account's client ID and return info about it.
146
-
114
+ }
147
115
 
116
+ // Fetch selected service account's client ID and return info about it.
148
117
  const selectedAccount = serviceAccounts.find(nextAccount => nextAccount.name === selectedName);
149
118
  return {
150
119
  clientId: selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.client_id,
@@ -153,9 +122,7 @@ const askDosaClientId = async (client, showWarning = true) => {
153
122
  };
154
123
  }
155
124
  };
156
-
157
125
  exports.askDosaClientId = askDosaClientId;
158
-
159
126
  const askNamespace = async (msg, defaultValue) => {
160
127
  const namespaces = await _Kubectl.kubectl.get('ns');
161
128
  if (namespaces.error) throw Error(namespaces.error);
@@ -166,7 +133,6 @@ const askNamespace = async (msg, defaultValue) => {
166
133
  value: 'CREATE_NEW'
167
134
  }, new _inquirer.default.Separator(), ...namespaces.data, new _inquirer.default.Separator()]
168
135
  });
169
-
170
136
  if (answer === 'CREATE_NEW') {
171
137
  const name = await (0, _basicPrompts.askInput)({
172
138
  msg: enterNamespaceName,
@@ -184,9 +150,7 @@ const askNamespace = async (msg, defaultValue) => {
184
150
  };
185
151
  }
186
152
  };
187
-
188
153
  exports.askNamespace = askNamespace;
189
-
190
154
  const askForSecretName = async (msg, defaultValue, options) => {
191
155
  return await (0, _basicPrompts.askInput)({
192
156
  msg,
@@ -194,9 +158,7 @@ const askForSecretName = async (msg, defaultValue, options) => {
194
158
  validate: (0, _basicPrompts.runValidations)((0, _basicPrompts.validateInputIsNew)(options, secretAlreadyExists), (0, _basicPrompts.validateRegex)(_regex.resourceRegex, (0, _regex.invalidResourceMsg)('Secret')))
195
159
  });
196
160
  };
197
-
198
161
  exports.askForSecretName = askForSecretName;
199
-
200
162
  const askIngestionProtocol = async () => {
201
163
  return await (0, _basicPrompts.askList)({
202
164
  msg: selectIngestionProtocol,
@@ -209,19 +171,14 @@ const askIngestionProtocol = async () => {
209
171
  default: _types.IngestionProtocol.Lumberjack
210
172
  });
211
173
  };
212
-
213
174
  exports.askIngestionProtocol = askIngestionProtocol;
214
-
215
175
  const askBundleType = async choices => await (0, _basicPrompts.askList)({
216
176
  msg: agentMessages.selectAgentType,
217
177
  choices: choices
218
178
  });
219
-
220
179
  exports.askBundleType = askBundleType;
221
-
222
180
  const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) => {
223
181
  let envs;
224
-
225
182
  if (isAxwayManaged == null) {
226
183
  // do not filter any environments
227
184
  const {
@@ -247,7 +204,6 @@ const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) =>
247
204
  });
248
205
  if (!axwayManagedEnvs) throw Error(envMessages.getEnvironmentsError);
249
206
  envs = axwayManagedEnvs;
250
-
251
207
  if (!isAxwayManaged) {
252
208
  const {
253
209
  data: allEnvs
@@ -257,14 +213,14 @@ const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) =>
257
213
  resourceType: 'Environment',
258
214
  resourceShortName: 'env'
259
215
  });
260
- if (!allEnvs) throw Error(envMessages.getEnvironmentsError); // Remove any axway managed envs from the array when isAxwayManaged is false
216
+ if (!allEnvs) throw Error(envMessages.getEnvironmentsError);
261
217
 
218
+ // Remove any axway managed envs from the array when isAxwayManaged is false
262
219
  envs = allEnvs.filter(env => {
263
220
  return !envs.find(axwayManagedEnv => env.name == axwayManagedEnv.name);
264
221
  });
265
222
  }
266
223
  }
267
-
268
224
  let answer = await (0, _basicPrompts.askList)({
269
225
  msg: envMessages.selectEnvironment,
270
226
  choices: [{
@@ -272,7 +228,6 @@ const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) =>
272
228
  value: 'CREATE_NEW'
273
229
  }, new _inquirer.default.Separator(), ...envs.map(e => e.name).sort((name1, name2) => name1.localeCompare(name2)), new _inquirer.default.Separator()]
274
230
  });
275
-
276
231
  if (answer === 'CREATE_NEW') {
277
232
  const name = await (0, _basicPrompts.askInput)({
278
233
  msg: envMessages.enterEnvironmentName,
@@ -290,9 +245,7 @@ const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) =>
290
245
  };
291
246
  }
292
247
  };
293
-
294
248
  exports.askEnvironmentName = askEnvironmentName;
295
-
296
249
  const askK8sClusterName = async (client, defsManager) => {
297
250
  const {
298
251
  data: k8sCluster
@@ -310,16 +263,12 @@ const askK8sClusterName = async (client, defsManager) => {
310
263
  });
311
264
  return name;
312
265
  };
313
-
314
266
  exports.askK8sClusterName = askK8sClusterName;
315
-
316
267
  const askAgentName = async (client, defsManager, agentType, scopeName) => {
317
268
  var _agents;
318
-
319
269
  let resourceType;
320
270
  let resourceShortName;
321
271
  let msg;
322
-
323
272
  switch (agentType) {
324
273
  case _types.AgentTypes.da:
325
274
  {
@@ -328,7 +277,6 @@ const askAgentName = async (client, defsManager, agentType, scopeName) => {
328
277
  msg = agentMessages.enterDiscoveryAgentName;
329
278
  break;
330
279
  }
331
-
332
280
  case _types.AgentTypes.ta:
333
281
  {
334
282
  resourceType = 'TraceabilityAgent';
@@ -337,7 +285,6 @@ const askAgentName = async (client, defsManager, agentType, scopeName) => {
337
285
  break;
338
286
  }
339
287
  }
340
-
341
288
  let {
342
289
  data: agents
343
290
  } = await (0, _getters.getListByResource)({
@@ -346,8 +293,8 @@ const askAgentName = async (client, defsManager, agentType, scopeName) => {
346
293
  resourceType,
347
294
  resourceShortName,
348
295
  scopeName
349
- }); // if there are no agents scoped to the env, make the agents list blank to validate against
350
-
296
+ });
297
+ // if there are no agents scoped to the env, make the agents list blank to validate against
351
298
  agents = (_agents = agents) !== null && _agents !== void 0 ? _agents : [];
352
299
  const name = await (0, _basicPrompts.askInput)({
353
300
  msg: msg,
@@ -356,6 +303,7 @@ const askAgentName = async (client, defsManager, agentType, scopeName) => {
356
303
  });
357
304
  return name;
358
305
  };
306
+
359
307
  /**
360
308
  * @description Create a secret that contains a public & private key pair for agents to connect to central.
361
309
  * If a user is creating a new service account, then the keys should be passed in as args.
@@ -365,10 +313,7 @@ const askAgentName = async (client, defsManager, agentType, scopeName) => {
365
313
  * @param publicKey The file path to the public key attached to the chosen service account.
366
314
  * @param privateKey The file path to the corresponding private key.
367
315
  */
368
-
369
-
370
316
  exports.askAgentName = askAgentName;
371
-
372
317
  const createAmplifyAgentKeysSecret = async (namespace, secretName, publicKeyName, publicKey, privateKeyName, privateKey) => {
373
318
  const {
374
319
  error
@@ -376,18 +321,14 @@ const createAmplifyAgentKeysSecret = async (namespace, secretName, publicKeyName
376
321
  if (error) throw new Error(error);
377
322
  console.log(`Created ${secretName} in the ${namespace} namespace.`);
378
323
  };
379
-
380
324
  exports.createAmplifyAgentKeysSecret = createAmplifyAgentKeysSecret;
381
-
382
325
  const createNamespace = async namespace => {
383
326
  const res = await _Kubectl.kubectl.create('ns', namespace);
384
327
  if (res.error) throw new Error(res.error);
385
328
  console.log(`Created namespace ${namespace}.`);
386
329
  return namespace;
387
330
  };
388
-
389
331
  exports.createNamespace = createNamespace;
390
-
391
332
  const createGatewayAgentCredsSecret = async (namespace, secretName, apiManagerAuthUser, apiManagerAuthPass, apiGatewayAuthUser, apiGatewayAuthPass) => {
392
333
  const {
393
334
  error
@@ -396,40 +337,31 @@ const createGatewayAgentCredsSecret = async (namespace, secretName, apiManagerAu
396
337
  --from-literal=APIMANAGER_AUTH_PASSWORD=${apiManagerAuthPass} \
397
338
  --from-literal=APIGATEWAY_AUTH_USERNAME=${apiGatewayAuthUser} \
398
339
  --from-literal=APIGATEWAY_AUTH_PASSWORD=${apiGatewayAuthPass}`);
399
-
400
340
  if (error) {
401
341
  throw Error(error);
402
342
  }
403
-
404
343
  console.log(`Created ${secretName} in the ${namespace} namespace.`);
405
344
  };
406
-
407
345
  exports.createGatewayAgentCredsSecret = createGatewayAgentCredsSecret;
408
-
409
346
  const askPublicKeyPath = async () => await (0, _basicPrompts.askInput)({
410
347
  msg: enterPublicKeyPath,
411
348
  defaultValue: 'public_key.pem'
412
349
  });
413
-
414
350
  exports.askPublicKeyPath = askPublicKeyPath;
415
-
416
351
  const askPrivateKeyPath = async () => await (0, _basicPrompts.askInput)({
417
352
  msg: enterPrivateKeyPath,
418
353
  defaultValue: 'private_key.pem'
419
354
  });
420
-
421
355
  exports.askPrivateKeyPath = askPrivateKeyPath;
422
-
423
356
  const askPublicAndPrivateKeysPath = async () => {
424
357
  console.log(_chalk.default.yellow('Please provide the same "private_key.pem" and "public_key.pem" that was used to create the selected Service Account.'));
425
358
  const publicKey = await askPublicKeyPath();
426
359
  const privateKey = await askPrivateKeyPath();
427
360
  return [publicKey, privateKey];
428
- }; // askToEnableTransactionLogging - asks Yes/No question to enable transaction logging, if Yes, configure values for environment variables.
429
-
361
+ };
430
362
 
363
+ // askToEnableTransactionLogging - asks Yes/No question to enable transaction logging, if Yes, configure values for environment variables.
431
364
  exports.askPublicAndPrivateKeysPath = askPublicAndPrivateKeysPath;
432
-
433
365
  const askToEnableTransactionLogging = async () => {
434
366
  console.log(_chalk.default.gray(transactionLoggingMessages.transactionLoggingInfoMsg));
435
367
  const enable = await (0, _basicPrompts.askList)({
@@ -437,7 +369,6 @@ const askToEnableTransactionLogging = async () => {
437
369
  choices: _types.YesNoChoices,
438
370
  default: _types.YesNo.No
439
371
  });
440
-
441
372
  if (enable === _types.YesNo.Yes) {
442
373
  console.log(_chalk.default.gray(transactionLoggingMessages.samplingPercentageInfoMsg));
443
374
  const samplingPercentage = await (0, _basicPrompts.askInput)({
@@ -446,7 +377,6 @@ const askToEnableTransactionLogging = async () => {
446
377
  validate: (0, _basicPrompts.runValidations)((0, _basicPrompts.validateRegex)(_regex.percentageRegex, _regex.invalidPercentage))
447
378
  });
448
379
  let shouldReportAllErrors = _types.YesNo.Yes;
449
-
450
380
  if (samplingPercentage < 100) {
451
381
  console.log(_chalk.default.gray(transactionLoggingMessages.reportAllErrorsMsg));
452
382
  shouldReportAllErrors = await (0, _basicPrompts.askList)({
@@ -455,7 +385,6 @@ const askToEnableTransactionLogging = async () => {
455
385
  default: _types.YesNo.Yes
456
386
  });
457
387
  }
458
-
459
388
  return {
460
389
  enabled: true,
461
390
  samplingPercentage: samplingPercentage,
@@ -469,5 +398,4 @@ const askToEnableTransactionLogging = async () => {
469
398
  };
470
399
  }
471
400
  };
472
-
473
401
  exports.askToEnableTransactionLogging = askToEnableTransactionLogging;