@axway/axway-central-cli 2.16.0 → 2.17.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/install/agents.js +9 -1
- package/dist/commands/install/apigeexSaasAgents.js +362 -0
- package/dist/commands/install/helpers/creators.js +5 -1
- package/dist/commands/install/helpers/regex.js +8 -2
- package/dist/common/basicPrompts.js +31 -1
- package/dist/common/types.js +15 -2
- package/dist/common/utils.js +26 -2
- package/package.json +1 -1
|
@@ -33,6 +33,8 @@ var azureAgents = _interopRequireWildcard(require("./azureAgents"));
|
|
|
33
33
|
|
|
34
34
|
var edgeAgents = _interopRequireWildcard(require("./edgeAgents"));
|
|
35
35
|
|
|
36
|
+
var apigeeSaaSAgents = _interopRequireWildcard(require("./apigeexSaasAgents"));
|
|
37
|
+
|
|
36
38
|
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
37
39
|
|
|
38
40
|
var istioAgents = _interopRequireWildcard(require("./istioAgents"));
|
|
@@ -61,11 +63,13 @@ const agentInstallFlows = {
|
|
|
61
63
|
[_types.GatewayTypes.EDGE_GATEWAY]: edgeAgents.EdgeInstallMethods,
|
|
62
64
|
[_types.GatewayTypes.EDGE_GATEWAY_ONLY]: edgeAgents.EdgeGWOnlyInstallMethods,
|
|
63
65
|
[_types.GatewayTypes.AWS_GATEWAY]: awsAgents.AWSInstallMethods,
|
|
66
|
+
[_types.GatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods,
|
|
64
67
|
[_types.GatewayTypes.AZURE_GATEWAY]: azureAgents.AzureInstallMethods,
|
|
65
68
|
[_types.GatewayTypes.ISTIO]: istioAgents.IstioInstallMethods
|
|
66
69
|
};
|
|
67
70
|
const saasAgentInstallFlows = {
|
|
68
|
-
[_types.GatewayTypes.AWS_GATEWAY]: saasAgents.AWSSaaSInstallMethods
|
|
71
|
+
[_types.GatewayTypes.AWS_GATEWAY]: saasAgents.AWSSaaSInstallMethods,
|
|
72
|
+
[_types.GatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
const createConfigBackup = async (configFiles, gatewayType) => {
|
|
@@ -143,6 +147,10 @@ const agents = {
|
|
|
143
147
|
choices: _types.YesNoChoices,
|
|
144
148
|
default: _types.YesNo.Yes
|
|
145
149
|
})) === _types.YesNo.Yes;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
|
|
153
|
+
installConfig.switches.isHostedInstall = true;
|
|
146
154
|
} // if gateway type is edge ask Gateway only or not
|
|
147
155
|
|
|
148
156
|
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.testables = exports.askBundleType = exports.APIGEEXSaaSInstallMethods = void 0;
|
|
7
|
+
|
|
8
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
|
|
10
|
+
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
11
|
+
|
|
12
|
+
var _basicPrompts = require("../../common/basicPrompts");
|
|
13
|
+
|
|
14
|
+
var _types = require("../../common/types");
|
|
15
|
+
|
|
16
|
+
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
17
|
+
|
|
18
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
19
|
+
|
|
20
|
+
var _utils = require("../../common/utils");
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
log
|
|
32
|
+
} = (0, _snooplogg.default)('central: install: agents: saas');
|
|
33
|
+
|
|
34
|
+
class DataplaneConfig {
|
|
35
|
+
constructor(type) {
|
|
36
|
+
_defineProperty(this, "type", void 0);
|
|
37
|
+
|
|
38
|
+
this.type = type || "";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class APIGEEXDataplaneConfig extends DataplaneConfig {
|
|
44
|
+
constructor(projectID, developerEmail, mode) {
|
|
45
|
+
super("Apigee");
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "projectID", void 0);
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "developerEmail", void 0);
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "mode", void 0);
|
|
52
|
+
|
|
53
|
+
this.projectID = projectID;
|
|
54
|
+
this.developerEmail = developerEmail;
|
|
55
|
+
this.mode = mode;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class SaasAgentValues {
|
|
61
|
+
constructor() {
|
|
62
|
+
_defineProperty(this, "frequencyDA", void 0);
|
|
63
|
+
|
|
64
|
+
_defineProperty(this, "queueDA", void 0);
|
|
65
|
+
|
|
66
|
+
_defineProperty(this, "frequencyTA", void 0);
|
|
67
|
+
|
|
68
|
+
_defineProperty(this, "dataplaneConfig", void 0);
|
|
69
|
+
|
|
70
|
+
_defineProperty(this, "centralConfig", void 0);
|
|
71
|
+
|
|
72
|
+
this.frequencyDA = '';
|
|
73
|
+
this.queueDA = false;
|
|
74
|
+
this.frequencyTA = '';
|
|
75
|
+
this.dataplaneConfig = new DataplaneConfig();
|
|
76
|
+
this.centralConfig = new _types.CentralAgentConfig();
|
|
77
|
+
} // getAccessData() {
|
|
78
|
+
// return ""
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class SaasAPIGEEXAgentValues extends SaasAgentValues {
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
|
|
88
|
+
_defineProperty(this, "authType", void 0);
|
|
89
|
+
|
|
90
|
+
_defineProperty(this, "clientEmailAddress", void 0);
|
|
91
|
+
|
|
92
|
+
_defineProperty(this, "credentialJSON", void 0);
|
|
93
|
+
|
|
94
|
+
_defineProperty(this, "projectID", void 0);
|
|
95
|
+
|
|
96
|
+
_defineProperty(this, "developerEmailAddress", void 0);
|
|
97
|
+
|
|
98
|
+
_defineProperty(this, "mode", void 0);
|
|
99
|
+
|
|
100
|
+
this.authType = APIGEEXAuthType.IMP_SVC_ACC;
|
|
101
|
+
this.clientEmailAddress = '';
|
|
102
|
+
this.credentialJSON = '';
|
|
103
|
+
this.projectID = '';
|
|
104
|
+
this.developerEmailAddress = '';
|
|
105
|
+
this.mode = _types.APIGEEXDISCOVERYMODES.PROXY;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getAccessData() {
|
|
109
|
+
let data = JSON.stringify({
|
|
110
|
+
client_email: this.clientEmailAddress
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (this.authType == APIGEEXAuthType.ACCESS_CREDENTIAL) {
|
|
114
|
+
data = JSON.stringify(this.credentialJSON);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
} // ConfigFiles - all the config file that are used in the setup
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
const ConfigFiles = {}; // APIGEEXAuthType - how the agent will authenticate to APIGEEX
|
|
124
|
+
|
|
125
|
+
var APIGEEXAuthType; // APIGEEX SaaSPrompts - all APIGEEX Saas prompts to the user for input
|
|
126
|
+
|
|
127
|
+
(function (APIGEEXAuthType) {
|
|
128
|
+
APIGEEXAuthType["IMP_SVC_ACC"] = "Impersonate Service Account";
|
|
129
|
+
APIGEEXAuthType["ACCESS_CREDENTIAL"] = "Access Credential";
|
|
130
|
+
})(APIGEEXAuthType || (APIGEEXAuthType = {}));
|
|
131
|
+
|
|
132
|
+
const SaasPrompts = {
|
|
133
|
+
AUTHENTICATION_TYPE: 'Authenticate with an Impersonation of a Service Account or by providing a Credential File',
|
|
134
|
+
PROJECT_ID: 'Enter the APIGEE X Project ID the agent will use',
|
|
135
|
+
DEVELOPER_EMAIL_ADDRESS: 'Enter the APIGEE X Developer Email Address the agent will use',
|
|
136
|
+
CLIENT_EMAIL_ADDRESS: 'Enter the Client Email Address the agent will use for the APIGEE X Service Account',
|
|
137
|
+
UPLOAD_CREDENTIAL_FILE: 'Upload a JSON Credential file to be used for APIGEE X Authentication',
|
|
138
|
+
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
139
|
+
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
140
|
+
QUEUE: 'Do you want to discover immediately after installation',
|
|
141
|
+
ENTER_MORE: 'Do you want to enter another {0} for {1}'
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const askBundleType = async () => {
|
|
145
|
+
return await (0, _basicPrompts.askList)({
|
|
146
|
+
msg: helpers.agentMessages.selectAgentType,
|
|
147
|
+
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
exports.askBundleType = askBundleType;
|
|
152
|
+
|
|
153
|
+
const askConfigType = async () => {
|
|
154
|
+
return _types.AgentConfigTypes.HOSTED;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const askForAPIGEEXCredentials = async hostedAgentValues => {
|
|
158
|
+
log("gathering access details for apigee x");
|
|
159
|
+
hostedAgentValues.projectID = await (0, _basicPrompts.askInput)({
|
|
160
|
+
msg: SaasPrompts.PROJECT_ID,
|
|
161
|
+
defaultValue: hostedAgentValues.projectID !== '' ? hostedAgentValues.projectID : undefined,
|
|
162
|
+
validate: (0, _basicPrompts.validateRegex)(helpers.APIGEEXRegexPatterns.APIGEEX_REGEXP_PROJECT_ID, helpers.invalidValueExampleErrMsg('Project ID', 'rd-amplify-apigee-x'))
|
|
163
|
+
}); // get developer email address
|
|
164
|
+
|
|
165
|
+
hostedAgentValues.developerEmailAddress = await (0, _basicPrompts.askInput)({
|
|
166
|
+
msg: SaasPrompts.DEVELOPER_EMAIL_ADDRESS,
|
|
167
|
+
defaultValue: hostedAgentValues.developerEmailAddress !== '' ? hostedAgentValues.developerEmailAddress : undefined,
|
|
168
|
+
allowEmptyInput: true
|
|
169
|
+
}); // Ask Auth type
|
|
170
|
+
|
|
171
|
+
hostedAgentValues.authType = await (0, _basicPrompts.askList)({
|
|
172
|
+
msg: SaasPrompts.AUTHENTICATION_TYPE,
|
|
173
|
+
default: APIGEEXAuthType.IMP_SVC_ACC,
|
|
174
|
+
choices: [{
|
|
175
|
+
name: APIGEEXAuthType.IMP_SVC_ACC,
|
|
176
|
+
value: APIGEEXAuthType.IMP_SVC_ACC
|
|
177
|
+
}, {
|
|
178
|
+
name: APIGEEXAuthType.ACCESS_CREDENTIAL,
|
|
179
|
+
value: APIGEEXAuthType.ACCESS_CREDENTIAL
|
|
180
|
+
}]
|
|
181
|
+
});
|
|
182
|
+
console.log(_chalk.default.gray("Please refer to docs.axway.com for information on creating the necessary APIGEE X IAM policies"));
|
|
183
|
+
|
|
184
|
+
if (hostedAgentValues.authType === APIGEEXAuthType.IMP_SVC_ACC) {
|
|
185
|
+
log("using impersonate service account authentication"); // get client email address
|
|
186
|
+
|
|
187
|
+
hostedAgentValues.clientEmailAddress = await (0, _basicPrompts.askInput)({
|
|
188
|
+
msg: SaasPrompts.CLIENT_EMAIL_ADDRESS,
|
|
189
|
+
defaultValue: hostedAgentValues.clientEmailAddress !== '' ? hostedAgentValues.clientEmailAddress : undefined,
|
|
190
|
+
allowEmptyInput: true
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
log("by uploading the credential file"); // fetch the path of the credential file
|
|
194
|
+
|
|
195
|
+
let credentialFilePath = '';
|
|
196
|
+
credentialFilePath = await (0, _basicPrompts.askInput)({
|
|
197
|
+
msg: SaasPrompts.UPLOAD_CREDENTIAL_FILE,
|
|
198
|
+
validate: (0, _basicPrompts.verifyApigeeXCredentialFile)()
|
|
199
|
+
});
|
|
200
|
+
hostedAgentValues.credentialJSON = await (0, _utils.loadAndVerifyApigeeXCredentialFile)(credentialFilePath);
|
|
201
|
+
console.log(hostedAgentValues.credentialJSON);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return hostedAgentValues;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const validateFrequency = () => input => {
|
|
208
|
+
let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
|
|
209
|
+
|
|
210
|
+
if (typeof val === "string") {
|
|
211
|
+
return val;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
let r = input.toString().match(/^(\d*)m/);
|
|
215
|
+
|
|
216
|
+
if (r) {
|
|
217
|
+
// only minutes
|
|
218
|
+
let mins = r[1];
|
|
219
|
+
|
|
220
|
+
if (parseInt(mins, 10) < 30) {
|
|
221
|
+
return "Minimum frequency is 30m";
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return true;
|
|
226
|
+
}; // @ts-ignore
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
const gatewayConnectivity = async installConfig => {
|
|
230
|
+
console.log('\nCONNECTION TO APIGEE X API GATEWAY:');
|
|
231
|
+
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
|
|
232
|
+
|
|
233
|
+
let hostedAgentValues = new SaasAgentValues();
|
|
234
|
+
|
|
235
|
+
if (installConfig.gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
|
|
236
|
+
// APIGEE X connection details
|
|
237
|
+
hostedAgentValues = new SaasAPIGEEXAgentValues();
|
|
238
|
+
hostedAgentValues = await askForAPIGEEXCredentials(hostedAgentValues);
|
|
239
|
+
} // Ask to queue discovery now
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
log("getting the frequency and if the agent should run now");
|
|
243
|
+
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."));
|
|
244
|
+
hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
|
|
245
|
+
msg: SaasPrompts.DA_FREQUENCY,
|
|
246
|
+
validate: validateFrequency(),
|
|
247
|
+
allowEmptyInput: true
|
|
248
|
+
});
|
|
249
|
+
hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
|
|
250
|
+
msg: SaasPrompts.QUEUE,
|
|
251
|
+
default: _types.YesNo.No,
|
|
252
|
+
choices: _types.YesNoChoices
|
|
253
|
+
})) === _types.YesNo.Yes;
|
|
254
|
+
|
|
255
|
+
if (installConfig.switches.isTaEnabled) {
|
|
256
|
+
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."));
|
|
257
|
+
hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
|
|
258
|
+
msg: SaasPrompts.TA_FREQUENCY,
|
|
259
|
+
defaultValue: "30m",
|
|
260
|
+
validate: validateFrequency(),
|
|
261
|
+
allowEmptyInput: true
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return hostedAgentValues;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const generateOutput = async installConfig => {
|
|
269
|
+
return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
|
|
273
|
+
var _dataplaneRes$securit, _dataplaneRes$securit2;
|
|
274
|
+
|
|
275
|
+
// grab key from data plane resource
|
|
276
|
+
let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
|
|
277
|
+
let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
|
|
278
|
+
|
|
279
|
+
if (key === "" || hash === "") {
|
|
280
|
+
throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
console.log(hostedAgentValues.getAccessData());
|
|
284
|
+
|
|
285
|
+
let encData = _crypto.default.publicEncrypt({
|
|
286
|
+
key: key,
|
|
287
|
+
padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
|
|
288
|
+
oaepHash: hash
|
|
289
|
+
}, Buffer.from(hostedAgentValues.getAccessData()));
|
|
290
|
+
|
|
291
|
+
return encData.toString("base64");
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
295
|
+
/**
|
|
296
|
+
* Create agent resources
|
|
297
|
+
*/
|
|
298
|
+
console.log("\n");
|
|
299
|
+
let apigeeXAgentValues = installConfig.gatewayConfig; // create the environment, if necessary
|
|
300
|
+
|
|
301
|
+
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
302
|
+
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
303
|
+
production: installConfig.centralConfig.production
|
|
304
|
+
}) : installConfig.centralConfig.ampcEnvInfo.name;
|
|
305
|
+
|
|
306
|
+
if (installConfig.gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
|
|
307
|
+
apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.projectID, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode);
|
|
308
|
+
} // create the data plane resource
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], apigeeXAgentValues.dataplaneConfig);
|
|
312
|
+
console.log(dataplaneRes); // create data plane secret resource
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(apigeeXAgentValues, dataplaneRes));
|
|
316
|
+
} catch (error) {
|
|
317
|
+
console.log(error);
|
|
318
|
+
console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
|
|
319
|
+
|
|
320
|
+
if (installConfig.centralConfig.ampcEnvInfo.isNew) {
|
|
321
|
+
await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
322
|
+
} else {
|
|
323
|
+
await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return;
|
|
327
|
+
} // create discovery agent resource
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
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);
|
|
331
|
+
|
|
332
|
+
if (installConfig.switches.isTaEnabled) {
|
|
333
|
+
// create traceability agent resource
|
|
334
|
+
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
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
console.log(await generateOutput(installConfig));
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const APIGEEXSaaSInstallMethods = {
|
|
342
|
+
GetBundleType: askBundleType,
|
|
343
|
+
GetDeploymentType: askConfigType,
|
|
344
|
+
AskGatewayQuestions: gatewayConnectivity,
|
|
345
|
+
FinalizeGatewayInstall: completeInstall,
|
|
346
|
+
ConfigFiles: [],
|
|
347
|
+
AgentNameMap: {
|
|
348
|
+
[_types.AgentTypes.da]: _types.AgentNames.APIGEEX_DA,
|
|
349
|
+
[_types.AgentTypes.ta]: _types.AgentNames.APIGEEX_TA
|
|
350
|
+
},
|
|
351
|
+
GatewayDisplay: _types.GatewayTypes.APIGEEX_GATEWAY
|
|
352
|
+
}; // These are the items that are not exported, but need to be for testing
|
|
353
|
+
|
|
354
|
+
exports.APIGEEXSaaSInstallMethods = APIGEEXSaaSInstallMethods;
|
|
355
|
+
const testables = {
|
|
356
|
+
SaasAgentValues,
|
|
357
|
+
SaasAPIGEEXAgentValues,
|
|
358
|
+
APIGEEXAuthType,
|
|
359
|
+
SaasPrompts,
|
|
360
|
+
ConfigFiles
|
|
361
|
+
};
|
|
362
|
+
exports.testables = testables;
|
|
@@ -178,6 +178,8 @@ const createNewDataPlaneResource = async (client, defsManager, envName, dataPlan
|
|
|
178
178
|
console.log(`Creating a new Dataplane resource, with type: ${dataPlaneType}.`); // NOTE: only a first found set is used
|
|
179
179
|
|
|
180
180
|
const defs = defsManager.findDefsByWord("dp");
|
|
181
|
+
console.log(dataPlaneType);
|
|
182
|
+
console.log(config);
|
|
181
183
|
|
|
182
184
|
if (!defs) {
|
|
183
185
|
throw Error(`the server doesn't have a resource type "Dataplane"`);
|
|
@@ -226,7 +228,9 @@ const createNewDataPlaneResource = async (client, defsManager, envName, dataPlan
|
|
|
226
228
|
exports.createNewDataPlaneResource = createNewDataPlaneResource;
|
|
227
229
|
|
|
228
230
|
const createNewDataPlaneSecretResource = async (client, defsManager, envName, dataPlaneType, dataPlaneName, accessData) => {
|
|
229
|
-
console.log(`Creating a new DataplaneSecret resource.`);
|
|
231
|
+
console.log(`Creating a new DataplaneSecret resource.`);
|
|
232
|
+
console.log(dataPlaneType);
|
|
233
|
+
console.log(accessData); // NOTE: only a first found set is used
|
|
230
234
|
|
|
231
235
|
const defs = defsManager.findDefsByWord("dps");
|
|
232
236
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.AzureRegexPatterns = exports.AWSRegexPatterns = void 0;
|
|
6
|
+
exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.AzureRegexPatterns = exports.AWSRegexPatterns = exports.APIGEEXRegexPatterns = void 0;
|
|
7
7
|
const resourceRegex = '^(?:[a-z0-9]*(?:\\.(?=[a-z0-9])|-+(?=[a-z0-9]))?)+[a-z0-9]$';
|
|
8
8
|
exports.resourceRegex = resourceRegex;
|
|
9
9
|
const namespaceRegex = '^[a-z0-9]?(?:[-a-z0-9]*[a-z0-9]){1,100}?$';
|
|
@@ -44,9 +44,15 @@ const AWSRegexPatterns = {
|
|
|
44
44
|
AWS_REGEXP_SECRET_ACCESS_KEY: '[a-zA-Z0-9+/]{40}',
|
|
45
45
|
AWS_REGEXP_ROLE_ARN: '^arn:aws[a-zA-Z-]*:iam::\\d{12}:role\\/?[a-zA-Z0-9+=,.@\\-_\\/]{1,128}$',
|
|
46
46
|
AWS_ACCESS_LOG_ARN: '^arn:aws[a-zA-Z-]*:logs:[a-zA-Z0-9\-]*:\\d{12}:log-group:[a-zA-Z0-9_\\-\\/\\.#]{1,512}$'
|
|
47
|
-
}; //
|
|
47
|
+
}; // APIGEEXRegexPatterns - regex patters to validate user inputs
|
|
48
48
|
|
|
49
49
|
exports.AWSRegexPatterns = AWSRegexPatterns;
|
|
50
|
+
const APIGEEXRegexPatterns = {
|
|
51
|
+
APIGEEX_REGEXP_PROJECT_ID: '^[a-z][a-z0-9-]{4,28}[a-z0-9]$',
|
|
52
|
+
AWS_REGEXP_EMAIL_ADDRESS: '^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'
|
|
53
|
+
}; // AzureRegexPatterns - regex patters to validate user inputs
|
|
54
|
+
|
|
55
|
+
exports.APIGEEXRegexPatterns = APIGEEXRegexPatterns;
|
|
50
56
|
const AzureRegexPatterns = {
|
|
51
57
|
azureApiManagementServiceNameRegex: '^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'
|
|
52
58
|
};
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = void 0;
|
|
6
|
+
exports.verifyApigeeXCredentialFile = exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = exports.MAX_FILE_SIZE = void 0;
|
|
7
7
|
|
|
8
8
|
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
9
9
|
|
|
10
|
+
var _fsExtra = require("fs-extra");
|
|
11
|
+
|
|
12
|
+
var _path = require("path");
|
|
13
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -31,6 +35,32 @@ const validateRegex = (regexp, message) => input => {
|
|
|
31
35
|
};
|
|
32
36
|
|
|
33
37
|
exports.validateRegex = validateRegex;
|
|
38
|
+
const MAX_FILE_SIZE = process.env.NODE_ENV === 'test' ? 1e5 : 20 * 1024 * 1024;
|
|
39
|
+
exports.MAX_FILE_SIZE = MAX_FILE_SIZE;
|
|
40
|
+
|
|
41
|
+
const verifyApigeeXCredentialFile = () => input => {
|
|
42
|
+
let stats;
|
|
43
|
+
let fileExtension = '';
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
stats = (0, _fsExtra.lstatSync)(input);
|
|
47
|
+
fileExtension = (0, _path.extname)(input);
|
|
48
|
+
|
|
49
|
+
if (!stats.isFile()) {
|
|
50
|
+
throw new Error(`Couldn't load the credential file: ${input}`);
|
|
51
|
+
} else if (stats.size >= MAX_FILE_SIZE) {
|
|
52
|
+
throw new Error(`File size too large`);
|
|
53
|
+
} else if (fileExtension !== '.json') {
|
|
54
|
+
throw new Error(`File extension is invalid, please provide '.json' file`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return true;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
throw new Error(`Couldn't find the credential file: ${input}`);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.verifyApigeeXCredentialFile = verifyApigeeXCredentialFile;
|
|
34
64
|
|
|
35
65
|
const validateValidRegex = () => input => {
|
|
36
66
|
try {
|
package/dist/common/types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.docsUrl = exports.commonCmdArgsDescription = exports.cliVersionHeader = exports.YesNoChoices = exports.YesNo = exports.WAIT_TIMEOUT = exports.TrueFalseChoices = exports.TrueFalse = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.SaaSGatewayTypes = exports.Regions = exports.PublicRepoUrl = exports.PublicDockerRepoBaseUrl = exports.Protocol = exports.ProdBaseUrls = exports.Platforms = exports.OutputTypes = exports.MAX_TABLE_STRING_LENGTH = exports.MAX_FILE_SIZE = exports.MAX_CACHE_FILE_SIZE = exports.LoggingSource = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.GatewayTypes = exports.GatewayTypeToDataPlane = exports.GatewayMode = exports.EnvironmentConfigInfo = exports.DosaAccount = exports.DataPlaneNames = exports.DOSAConfigInfo = exports.ConfigTypes = exports.CloudFormationConfig = exports.Certificate = exports.CentralAgentConfig = exports.CACHE_FILE_TTL_MILLISECONDS = exports.BundleType = exports.BasePaths = exports.AuthUrls = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.AWSRegions = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
|
|
6
|
+
exports.docsUrl = exports.commonCmdArgsDescription = exports.cliVersionHeader = exports.YesNoChoices = exports.YesNo = exports.WAIT_TIMEOUT = exports.TrueFalseChoices = exports.TrueFalse = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.SaaSGatewayTypes = exports.Regions = exports.PublicRepoUrl = exports.PublicDockerRepoBaseUrl = exports.Protocol = exports.ProdBaseUrls = exports.Platforms = exports.OutputTypes = exports.MAX_TABLE_STRING_LENGTH = exports.MAX_FILE_SIZE = exports.MAX_CACHE_FILE_SIZE = exports.LoggingSource = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.GatewayTypes = exports.GatewayTypeToDataPlane = exports.GatewayMode = exports.EnvironmentConfigInfo = exports.DosaAccount = exports.DataPlaneNames = exports.DOSAConfigInfo = exports.ConfigTypes = exports.CloudFormationConfig = exports.Certificate = exports.CentralAgentConfig = exports.CACHE_FILE_TTL_MILLISECONDS = exports.BundleType = exports.BasePaths = exports.AuthUrls = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.AWSRegions = exports.APIGEEXDISCOVERYMODES = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
|
|
7
7
|
|
|
8
8
|
var _dataService = require("./dataService");
|
|
9
9
|
|
|
@@ -282,6 +282,8 @@ exports.AgentNames = AgentNames;
|
|
|
282
282
|
(function (AgentNames) {
|
|
283
283
|
AgentNames["AWS_DA"] = "aws-apigw-discovery-agent";
|
|
284
284
|
AgentNames["AWS_TA"] = "aws-apigw-traceability-agent";
|
|
285
|
+
AgentNames["APIGEEX_DA"] = "apigee-discovery-agent";
|
|
286
|
+
AgentNames["APIGEEX_TA"] = "apigee-traceability-agent";
|
|
285
287
|
AgentNames["AZURE_DA"] = "azure-discovery-agent";
|
|
286
288
|
AgentNames["AZURE_TA"] = "azure-traceability-agent";
|
|
287
289
|
AgentNames["EDGE_DA"] = "v7-discovery-agent";
|
|
@@ -294,6 +296,7 @@ exports.GatewayTypes = GatewayTypes;
|
|
|
294
296
|
(function (GatewayTypes) {
|
|
295
297
|
GatewayTypes["EDGE_GATEWAY"] = "Amplify API Gateway";
|
|
296
298
|
GatewayTypes["AWS_GATEWAY"] = "Amazon API Gateway";
|
|
299
|
+
GatewayTypes["APIGEEX_GATEWAY"] = "Apigee X Gateway";
|
|
297
300
|
GatewayTypes["AZURE_GATEWAY"] = "Azure API Gateway";
|
|
298
301
|
GatewayTypes["ISTIO"] = "Istio";
|
|
299
302
|
GatewayTypes["EDGE_GATEWAY_ONLY"] = "Amplify API Gateway only";
|
|
@@ -304,6 +307,7 @@ exports.SaaSGatewayTypes = SaaSGatewayTypes;
|
|
|
304
307
|
|
|
305
308
|
(function (SaaSGatewayTypes) {
|
|
306
309
|
SaaSGatewayTypes[SaaSGatewayTypes["AWS_GATEWAY"] = 0] = "AWS_GATEWAY";
|
|
310
|
+
SaaSGatewayTypes[SaaSGatewayTypes["APIGEEX_GATEWAY"] = 1] = "APIGEEX_GATEWAY";
|
|
307
311
|
})(SaaSGatewayTypes || (exports.SaaSGatewayTypes = SaaSGatewayTypes = {}));
|
|
308
312
|
|
|
309
313
|
let DataPlaneNames;
|
|
@@ -325,7 +329,8 @@ const GatewayTypeToDataPlane = {
|
|
|
325
329
|
[GatewayTypes.EDGE_GATEWAY_ONLY]: DataPlaneNames.EDGE,
|
|
326
330
|
[GatewayTypes.AWS_GATEWAY]: DataPlaneNames.AWS,
|
|
327
331
|
[GatewayTypes.AZURE_GATEWAY]: DataPlaneNames.AZURE,
|
|
328
|
-
[GatewayTypes.ISTIO]: 'Istio'
|
|
332
|
+
[GatewayTypes.ISTIO]: 'Istio',
|
|
333
|
+
[GatewayTypes.APIGEEX_GATEWAY]: DataPlaneNames.APIGEE
|
|
329
334
|
};
|
|
330
335
|
exports.GatewayTypeToDataPlane = GatewayTypeToDataPlane;
|
|
331
336
|
let AgentResourceKind;
|
|
@@ -358,6 +363,14 @@ exports.AWSRegions = AWSRegions;
|
|
|
358
363
|
AWSRegions["EU_WEST_3"] = "eu-west-3";
|
|
359
364
|
})(AWSRegions || (exports.AWSRegions = AWSRegions = {}));
|
|
360
365
|
|
|
366
|
+
let APIGEEXDISCOVERYMODES;
|
|
367
|
+
exports.APIGEEXDISCOVERYMODES = APIGEEXDISCOVERYMODES;
|
|
368
|
+
|
|
369
|
+
(function (APIGEEXDISCOVERYMODES) {
|
|
370
|
+
APIGEEXDISCOVERYMODES["PROXY"] = "proxy";
|
|
371
|
+
APIGEEXDISCOVERYMODES["PRODUCT"] = "product";
|
|
372
|
+
})(APIGEEXDISCOVERYMODES || (exports.APIGEEXDISCOVERYMODES = APIGEEXDISCOVERYMODES = {}));
|
|
373
|
+
|
|
361
374
|
class EnvironmentConfigInfo {
|
|
362
375
|
constructor() {
|
|
363
376
|
_defineProperty(this, "name", void 0);
|
package/dist/common/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FormatString = FormatString;
|
|
7
|
-
exports.parseScopeParam = exports.loadAndVerifySpecs = exports.isWindows = exports.isValidJson = exports.isApiServerErrorType = exports.isApiServerErrorResponseType = exports.hbsCompare = exports.getConfig = exports.configFile = exports.compareResourcesByKindDesc = exports.compareResourcesByKindAsc = exports.buildTemplate = exports.buildGenericResource = void 0;
|
|
7
|
+
exports.parseScopeParam = exports.loadAndVerifySpecs = exports.loadAndVerifyApigeeXCredentialFile = exports.isWindows = exports.isValidJson = exports.isApiServerErrorType = exports.isApiServerErrorResponseType = exports.hbsCompare = exports.getConfig = exports.configFile = exports.compareResourcesByKindDesc = exports.compareResourcesByKindAsc = exports.buildTemplate = exports.buildGenericResource = void 0;
|
|
8
8
|
exports.sanitizeMetadata = sanitizeMetadata;
|
|
9
9
|
exports.writeToFile = exports.writeTemplates = exports.verifyScopeParam = exports.verifyFile = exports.transformSimpleFilters = void 0;
|
|
10
10
|
|
|
@@ -412,4 +412,28 @@ function FormatString(str, ...val) {
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
return str;
|
|
415
|
-
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Loads and parse file from path, accepts JSON file. Also validates additional details.
|
|
418
|
+
* @param credentialFilePath file path
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
const loadAndVerifyApigeeXCredentialFile = async credentialFilePath => {
|
|
423
|
+
// Load the given JSON file.
|
|
424
|
+
let fileInfo = '';
|
|
425
|
+
|
|
426
|
+
try {
|
|
427
|
+
fileInfo = await (0, _fsExtra.readJson)(credentialFilePath);
|
|
428
|
+
} catch (e) {
|
|
429
|
+
throw new Error(e.reason);
|
|
430
|
+
} // Do not continue if given an empty file.
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
if (fileInfo === '') throw new Error(`File is empty.`); // TODO: Validate additional details if needed
|
|
434
|
+
// Return loaded info.
|
|
435
|
+
|
|
436
|
+
return fileInfo;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
exports.loadAndVerifyApigeeXCredentialFile = loadAndVerifyApigeeXCredentialFile;
|