@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,32 +4,48 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getTraceabilityConfig = exports.getCentralConfig = exports.getApicDeployment = exports.finalizeCentralInstall = void 0;
7
+
7
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
+
8
10
  var _basicPrompts = require("../../common/basicPrompts");
11
+
9
12
  var _CliConfigManager = require("../../common/CliConfigManager");
13
+
10
14
  var _CoreConfigController = require("../../common/CoreConfigController");
15
+
11
16
  var _types = require("../../common/types");
17
+
12
18
  var _utils = require("../../common/utils");
19
+
13
20
  var _awsAgents = require("./awsAgents");
21
+
14
22
  var helpers = _interopRequireWildcard(require("./helpers"));
15
- 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); }
16
- 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; }
23
+
24
+ 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); }
25
+
26
+ 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; }
27
+
17
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
18
30
  //
19
31
  // Complex prompts
20
32
  //
21
33
  const askTeamName = async client => {
22
34
  var _teams$find;
35
+
23
36
  const teams = await client.getTeams();
37
+
24
38
  if (!(teams !== null && teams !== void 0 && teams.length)) {
25
39
  throw new Error('Account has no teams!');
26
40
  }
41
+
27
42
  return (0, _basicPrompts.askList)({
28
43
  msg: helpers.envMessages.selectTeam,
29
44
  choices: teams.map(t => t.name).sort((name1, name2) => name1.localeCompare(name2)),
30
45
  default: (_teams$find = teams.find(t => t.default)) === null || _teams$find === void 0 ? void 0 : _teams$find.name
31
46
  });
32
47
  };
48
+
33
49
  const askIsProductionEnvironment = async () => {
34
50
  return (await (0, _basicPrompts.askList)({
35
51
  msg: helpers.envMessages.isProduction,
@@ -37,14 +53,16 @@ const askIsProductionEnvironment = async () => {
37
53
  default: _types.YesNo.Yes
38
54
  })) === _types.YesNo.Yes;
39
55
  };
56
+
40
57
  const getTraceabilityConfig = async installConfig => {
41
58
  let traceabilityConfig = new _types.TraceabilityConfig();
59
+
42
60
  if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY && installConfig.gatewayConfig.cloudFormationConfig.DeploymentType === _awsAgents.DeploymentTypes.ECS_FARGATE) {
43
61
  return traceabilityConfig;
44
62
  }
45
- traceabilityConfig.usageReportingOffline = installConfig.bundleType === _types.BundleType.TRACEABILITY_OFFLINE;
46
63
 
47
- // Do not ask Traceability questions in offline mode
64
+ traceabilityConfig.usageReportingOffline = installConfig.bundleType === _types.BundleType.TRACEABILITY_OFFLINE; // Do not ask Traceability questions in offline mode
65
+
48
66
  if (!traceabilityConfig.usageReportingOffline) {
49
67
  console.log('\nCONNECTION TO TRACEABILITY MODULE:');
50
68
  const {
@@ -59,87 +77,100 @@ const getTraceabilityConfig = async installConfig => {
59
77
  traceabilityConfig.protocol = traceabilityProtocol;
60
78
  traceabilityConfig.host = helpers.getIngestionHost(installConfig.centralConfig.region, _CoreConfigController.CoreConfigController.getEnv(), installConfig.centralConfig.deployment, traceabilityProtocol);
61
79
  }
80
+
62
81
  return traceabilityConfig;
63
82
  };
83
+
64
84
  exports.getTraceabilityConfig = getTraceabilityConfig;
85
+
65
86
  const getCentralConfig = async (apiServerClient, platformClient, defsManager, apicDeployment, installConfig) => {
66
87
  // initiate CentralAgentConfig
67
88
  let centralConfig = installConfig.centralConfig;
68
89
  await centralConfig.setBaseHost();
69
90
  centralConfig.authUrl = `${_CoreConfigController.CoreConfigController.getAuthUrl()}/auth`;
70
91
  centralConfig.region = String(apiServerClient.region || (await (0, _utils.getConfig)())[_types.ConfigTypes.REGION] || _types.Regions.US).toUpperCase();
71
- centralConfig.deployment = apicDeployment || getApicDeployment(centralConfig.region, _CoreConfigController.CoreConfigController.getEnv());
92
+ centralConfig.deployment = apicDeployment || getApicDeployment(centralConfig.region, _CoreConfigController.CoreConfigController.getEnv()); // apic config
72
93
 
73
- // apic config
74
94
  console.log('\nCONNECTION TO AMPLIFY PLATFORM:');
75
- console.log(_chalk.default.gray(`The agents need access to the Amplify Platform to register services.`));
95
+ console.log(_chalk.default.gray(`The agents need access to the Amplify Platform to register services.`)); // create/find environment
76
96
 
77
- // create/find environment
78
97
  centralConfig.orgId = await helpers.getCurrentUserOrgId();
79
98
  centralConfig.ampcEnvInfo = await helpers.askEnvironmentName(apiServerClient, defsManager, centralConfig.axwayManaged);
80
99
  centralConfig.production = centralConfig.ampcEnvInfo.isNew ? await askIsProductionEnvironment() : false;
100
+
81
101
  if (!installConfig.switches.isOrgRep) {
82
102
  centralConfig.ampcTeamName = await askTeamName(platformClient);
83
103
  }
104
+
84
105
  centralConfig.ampcDosaInfo = {
85
106
  clientId: '',
86
107
  name: '',
87
108
  isNew: false
88
109
  };
110
+
89
111
  if (installConfig.bundleType !== _types.BundleType.TRACEABILITY_OFFLINE && !installConfig.switches.isHostedInstall) {
90
112
  centralConfig.ampcDosaInfo = await helpers.askDosaClientId(platformClient);
91
- }
113
+ } // Get the DA Agent name
114
+
115
+
116
+ centralConfig.daAgentName = ''; // Istio will not prompt for agent name. Remove when that ability exists
92
117
 
93
- // Get the DA Agent name
94
- centralConfig.daAgentName = '';
95
- // Istio will not prompt for agent name. Remove when that ability exists
96
118
  if (installConfig.switches.isDaEnabled && !installConfig.switches.isHostedInstall) {
97
119
  centralConfig.daAgentName = await helpers.askAgentName(apiServerClient, defsManager, _types.AgentTypes.da, centralConfig.ampcEnvInfo.name);
98
- }
120
+ } // Get the TA Agent name
121
+
99
122
 
100
- // Get the TA Agent name
101
123
  centralConfig.taAgentName = '';
124
+
102
125
  if (installConfig.switches.isTaEnabled && !installConfig.switches.isHostedInstall) {
103
126
  centralConfig.taAgentName = await helpers.askAgentName(apiServerClient, defsManager, _types.AgentTypes.ta, centralConfig.ampcEnvInfo.name);
104
127
  }
128
+
105
129
  return centralConfig;
106
130
  };
131
+
107
132
  exports.getCentralConfig = getCentralConfig;
133
+
108
134
  const finalizeCentralInstall = async (apiServerClient, platformClient, defsManager, installConfig) => {
109
135
  /**
110
136
  * Create agent resources
111
137
  */
112
138
  console.log('Creating agent resources');
139
+
113
140
  if (installConfig.centralConfig.ampcDosaInfo.isNew) {
114
141
  installConfig.centralConfig.dosaAccount = await helpers.createDosaAndCerts(platformClient, installConfig.centralConfig.ampcDosaInfo.name);
115
142
  } else {
116
143
  installConfig.centralConfig.dosaAccount.clientId = installConfig.centralConfig.ampcDosaInfo.clientId;
117
144
  }
118
- installConfig.centralConfig.dosaAccount.updateKeyTemplateValues(installConfig.deploymentType);
119
145
 
120
- // environment name
146
+ installConfig.centralConfig.dosaAccount.updateKeyTemplateValues(installConfig.deploymentType); // environment name
147
+
121
148
  installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
122
149
  axwayManaged: installConfig.centralConfig.axwayManaged,
123
150
  production: installConfig.centralConfig.production
124
- }) : installConfig.centralConfig.ampcEnvInfo.name;
151
+ }) : installConfig.centralConfig.ampcEnvInfo.name; // Create DiscoveryAgent Resource unless gateway type is Istio. This can be removed when this is available for Istio
125
152
 
126
- // Create DiscoveryAgent Resource unless gateway type is Istio. This can be removed when this is available for Istio
127
153
  if (installConfig.centralConfig.daAgentName != '') {
128
154
  installConfig.centralConfig.daAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.da, _types.AgentTypes.da, installConfig.centralConfig.ampcTeamName, installConfig.centralConfig.daAgentName);
129
- }
155
+ } // Create TraceabilityAgent Resource
156
+
130
157
 
131
- // Create TraceabilityAgent Resource
132
158
  if (installConfig.centralConfig.taAgentName != '') {
133
159
  installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ta, _types.AgentTypes.ta, installConfig.centralConfig.ampcTeamName, installConfig.centralConfig.taAgentName);
134
160
  }
161
+
135
162
  if (installConfig.bundleType === _types.BundleType.TRACEABILITY_OFFLINE || installConfig.gatewayType === _types.GatewayTypes.ISTIO) {
136
163
  installConfig.centralConfig.environmentId = await helpers.getEnvironmentId(apiServerClient, defsManager, installConfig.centralConfig.environment);
137
164
  }
165
+
138
166
  return installConfig;
139
167
  };
168
+
140
169
  exports.finalizeCentralInstall = finalizeCentralInstall;
170
+
141
171
  const getApicDeployment = (region, env) => {
142
172
  var _deployments$region;
173
+
143
174
  const deployments = {
144
175
  [_types.Regions.US]: {
145
176
  [_types.Platforms.prod]: _types.APICDeployments.US,
@@ -157,4 +188,5 @@ const getApicDeployment = (region, env) => {
157
188
  const savedDeployment = new _CliConfigManager.CliConfigManager().getAll()['apic-deployment'];
158
189
  return savedDeployment || (deployments === null || deployments === void 0 ? void 0 : (_deployments$region = deployments[region]) === null || _deployments$region === void 0 ? void 0 : _deployments$region[env]) || _types.APICDeployments.US;
159
190
  };
191
+
160
192
  exports.getApicDeployment = getApicDeployment;
@@ -4,20 +4,33 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.create = void 0;
7
+
7
8
  var _cliKit = require("cli-kit");
9
+
8
10
  var _formData = _interopRequireDefault(require("form-data"));
11
+
9
12
  var _fsExtra = require("fs-extra");
13
+
10
14
  var _ora = _interopRequireDefault(require("ora"));
15
+
11
16
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
17
+
12
18
  var _dataService = require("../../common/dataService");
19
+
13
20
  var _errorHandler = require("../../common/errorHandler");
21
+
14
22
  var _resultsRenderers = require("../../common/resultsRenderers");
23
+
15
24
  var _types = require("../../common/types");
25
+
16
26
  var _utils = require("../../common/utils");
27
+
17
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
18
30
  const {
19
31
  log
20
32
  } = (0, _snooplogg.default)('central: proxies: create');
33
+
21
34
  const action = async ({
22
35
  argv,
23
36
  console
@@ -35,6 +48,7 @@ const action = async ({
35
48
  spinner: 'dots3',
36
49
  text: 'Creating API Proxy'
37
50
  }).start() : null;
51
+
38
52
  try {
39
53
  log(`Verifying file: ${proxyDefinition}`);
40
54
  (0, _utils.verifyFile)(proxyDefinition);
@@ -58,7 +72,8 @@ const action = async ({
58
72
  spinner && spinner.stop();
59
73
  }
60
74
  };
61
- const create = exports.create = {
75
+
76
+ const create = {
62
77
  title: 'Create Amplify Central Proxy',
63
78
  desc: '',
64
79
  options: {
@@ -70,4 +85,5 @@ const create = exports.create = {
70
85
  required: true
71
86
  }],
72
87
  action
73
- };
88
+ };
89
+ exports.create = create;
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.proxies = void 0;
7
+
7
8
  var _create = require("./create");
9
+
8
10
  var _promote = require("./promote");
11
+
9
12
  var _types = require("../../common/types");
10
- const proxies = exports.proxies = {
13
+
14
+ const proxies = {
11
15
  action: () => {
12
16
  throw new Error(`Missing one of required commands: [create, promote]`);
13
17
  },
@@ -16,9 +20,9 @@ const proxies = exports.proxies = {
16
20
  promote: _promote.promote
17
21
  },
18
22
  desc: 'Manage API proxies',
19
- options: {
20
- ..._types.commonCmdArgsDescription,
23
+ options: { ..._types.commonCmdArgsDescription,
21
24
  '--client-id [value]': `Override your DevOps account's client ID`,
22
25
  '--json': 'Show JSON output'
23
26
  }
24
- };
27
+ };
28
+ exports.proxies = proxies;
@@ -4,20 +4,33 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.promote = void 0;
7
+
7
8
  var _cliKit = require("cli-kit");
9
+
8
10
  var _formData = _interopRequireDefault(require("form-data"));
11
+
9
12
  var _fsExtra = require("fs-extra");
13
+
10
14
  var _ora = _interopRequireDefault(require("ora"));
15
+
11
16
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
17
+
12
18
  var _dataService = require("../../common/dataService");
19
+
13
20
  var _errorHandler = require("../../common/errorHandler");
21
+
14
22
  var _resultsRenderers = require("../../common/resultsRenderers");
23
+
15
24
  var _types = require("../../common/types");
25
+
16
26
  var _utils = require("../../common/utils");
27
+
17
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
18
30
  const {
19
31
  log
20
32
  } = (0, _snooplogg.default)('central: proxies: promote');
33
+
21
34
  const action = async ({
22
35
  argv,
23
36
  console
@@ -36,6 +49,7 @@ const action = async ({
36
49
  spinner: 'dots3',
37
50
  text: `Promoting API Proxy to ${target}`
38
51
  }).start() : null;
52
+
39
53
  try {
40
54
  log(`Verifying file: ${proxyDefinition}`);
41
55
  (0, _utils.verifyFile)(proxyDefinition);
@@ -49,10 +63,13 @@ const action = async ({
49
63
  const body = new _formData.default();
50
64
  body.append('config', (0, _fsExtra.createReadStream)(proxyDefinition));
51
65
  body.append('target', target);
66
+
52
67
  if (source) {
53
68
  body.append('source', source);
54
69
  }
70
+
55
71
  const response = await service.postFormData('/promote', body);
72
+
56
73
  if (spinner) {
57
74
  spinner.succeed((0, _cliKit.chalk)`{greenBright The deployed service can now be accessed at {cyan.underline ${response.url}}}`);
58
75
  response.apiKeys && spinner.succeed((0, _cliKit.chalk)`{greenBright You can access it with these API Keys: {cyan ${response.apiKeys}}}`);
@@ -65,7 +82,8 @@ const action = async ({
65
82
  spinner && spinner.stop();
66
83
  }
67
84
  };
68
- const promote = exports.promote = {
85
+
86
+ const promote = {
69
87
  title: 'Promote Amplify Central proxy',
70
88
  desc: '',
71
89
  args: [{
@@ -81,4 +99,5 @@ const promote = exports.promote = {
81
99
  }
82
100
  },
83
101
  action
84
- };
102
+ };
103
+ exports.promote = promote;