@axway/axway-central-cli 4.5.0 → 4.6.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/.security-profile-branches.json +18 -0
- package/package.json +1 -1
- package/dist/cli.js +0 -71
- package/dist/commands/apply/index.js +0 -112
- package/dist/commands/completion/index.js +0 -100
- package/dist/commands/config/common/index.js +0 -28
- package/dist/commands/config/index.js +0 -20
- package/dist/commands/config/list.js +0 -24
- package/dist/commands/config/set.js +0 -102
- package/dist/commands/config/unset.js +0 -48
- package/dist/commands/create/agentResource.js +0 -108
- package/dist/commands/create/environment.js +0 -62
- package/dist/commands/create/index.js +0 -109
- package/dist/commands/create/serviceAccount.js +0 -15
- package/dist/commands/delete/index.js +0 -196
- package/dist/commands/edit/environment.js +0 -101
- package/dist/commands/edit/index.js +0 -28
- package/dist/commands/get/index.js +0 -272
- package/dist/commands/install/agents.js +0 -290
- package/dist/commands/install/apigeexAgents.js +0 -223
- package/dist/commands/install/apigeexSaasAgents.js +0 -300
- package/dist/commands/install/awsAgents.js +0 -525
- package/dist/commands/install/awsSaasAgents.js +0 -508
- package/dist/commands/install/azureAgents.js +0 -242
- package/dist/commands/install/azureSaasAgents.js +0 -519
- package/dist/commands/install/backstageAgents.js +0 -167
- package/dist/commands/install/edgeAgents.js +0 -409
- package/dist/commands/install/gitHubSaasAgents.js +0 -294
- package/dist/commands/install/gitLabAgents.js +0 -178
- package/dist/commands/install/graylogAgent.js +0 -147
- package/dist/commands/install/helpers/creators.js +0 -359
- package/dist/commands/install/helpers/deleters.js +0 -36
- package/dist/commands/install/helpers/getters.js +0 -95
- package/dist/commands/install/helpers/index.js +0 -267
- package/dist/commands/install/helpers/inputs.js +0 -593
- package/dist/commands/install/helpers/regex.js +0 -67
- package/dist/commands/install/helpers/templates/apigeexTemplates.js +0 -109
- package/dist/commands/install/helpers/templates/awsTemplates.js +0 -129
- package/dist/commands/install/helpers/templates/azureTemplates.js +0 -125
- package/dist/commands/install/helpers/templates/backstageTemplates.js +0 -95
- package/dist/commands/install/helpers/templates/edgeTemplates.js +0 -360
- package/dist/commands/install/helpers/templates/gitLabTemplates.js +0 -66
- package/dist/commands/install/helpers/templates/graylogTemplates.js +0 -75
- package/dist/commands/install/helpers/templates/ibmAPIConnectTemplates.js +0 -116
- package/dist/commands/install/helpers/templates/istioTemplates.js +0 -214
- package/dist/commands/install/helpers/templates/kafkaTemplates.js +0 -194
- package/dist/commands/install/helpers/templates/sapApiPortalTemplates.js +0 -114
- package/dist/commands/install/helpers/templates/softwareAGWebMethodsTemplates.js +0 -93
- package/dist/commands/install/helpers/templates/traceableTemplates.js +0 -135
- package/dist/commands/install/helpers/templates/wso2Templates.js +0 -85
- package/dist/commands/install/helpers/util.js +0 -26
- package/dist/commands/install/ibmAPIConnectAgents.js +0 -213
- package/dist/commands/install/index.js +0 -36
- package/dist/commands/install/istioAgents.js +0 -346
- package/dist/commands/install/kafkaAgents.js +0 -303
- package/dist/commands/install/platform.js +0 -175
- package/dist/commands/install/sapApiPortalAgents.js +0 -198
- package/dist/commands/install/softwareAGWebMethodsAgents.js +0 -161
- package/dist/commands/install/swaggerHubSaasAgents.js +0 -272
- package/dist/commands/install/traceableAgents.js +0 -257
- package/dist/commands/install/traceableSaasAgents.js +0 -275
- package/dist/commands/install/wso2Agents.js +0 -163
- package/dist/commands/productize/helpers/productizationHelper.js +0 -408
- package/dist/commands/productize/index.js +0 -99
- package/dist/common/ApiServerClient.js +0 -1109
- package/dist/common/CacheController.js +0 -146
- package/dist/common/CliConfigManager.js +0 -76
- package/dist/common/CompositeError.js +0 -95
- package/dist/common/CoreConfigController.js +0 -174
- package/dist/common/DefinitionsManager.js +0 -298
- package/dist/common/Kubectl.js +0 -68
- package/dist/common/PlatformClient.js +0 -128
- package/dist/common/Renderer.js +0 -409
- package/dist/common/TmpFile.js +0 -96
- package/dist/common/bashCommands.js +0 -97
- package/dist/common/basicPrompts.js +0 -160
- package/dist/common/dataService.js +0 -312
- package/dist/common/errorHandler.js +0 -46
- package/dist/common/modules.d.js +0 -1
- package/dist/common/resultsRenderers.js +0 -164
- package/dist/common/types.js +0 -746
- package/dist/common/utils.js +0 -476
- package/dist/main.js +0 -8
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.testables = exports.gatewayConnectivity = exports.defaultLogFiles = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.ConfigFiles = exports.ApigeeXInstallMethods = void 0;
|
|
7
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
|
-
var _basicPrompts = require("../../common/basicPrompts");
|
|
10
|
-
var _types = require("../../common/types");
|
|
11
|
-
var _utils = require("../../common/utils");
|
|
12
|
-
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
13
|
-
var _apigeexTemplates = require("./helpers/templates/apigeexTemplates");
|
|
14
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
const {
|
|
18
|
-
log
|
|
19
|
-
} = (0, _snooplogg.default)('engage: install: agents: apigeeX');
|
|
20
|
-
const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.APIGEEX_DA}`;
|
|
21
|
-
const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.APIGEEX_TA}`;
|
|
22
|
-
const defaultLogFiles = exports.defaultLogFiles = '/group-*_instance-*.log';
|
|
23
|
-
|
|
24
|
-
// ConfigFiles - all the config file that are used in the setup
|
|
25
|
-
const ConfigFiles = exports.ConfigFiles = {
|
|
26
|
-
DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
|
|
27
|
-
TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`,
|
|
28
|
-
ApigeeXDABinaryFile: 'discovery_agent',
|
|
29
|
-
ApigeeXDAYaml: 'discovery_agent.yml',
|
|
30
|
-
ApigeeXTABinaryFile: 'traceability_agent',
|
|
31
|
-
ApigeeXTAYaml: 'traceability_agent.yml'
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// ApigeeXPrompts - prompts for user inputs
|
|
35
|
-
const ApigeeXPrompts = {
|
|
36
|
-
AUTHENTICATION_TYPE: 'Authenticate with an Impersonation of a Service Account or by providing a Credential File',
|
|
37
|
-
PROJECT_ID: 'Enter the APIGEE X Project ID the agent will use',
|
|
38
|
-
DEVELOPER_EMAIL_ADDRESS: 'Enter the APIGEE X Developer Email Address the agent will use',
|
|
39
|
-
AUTH_FILE_NAME: 'Enter the GCP key file name (place in the same directory as your Axway public and private keys)',
|
|
40
|
-
UPLOAD_CREDENTIAL_FILE: 'Upload a JSON Credential file to be used for APIGEE X Authentication',
|
|
41
|
-
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
42
|
-
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
43
|
-
QUEUE: 'Do you want to discover immediately after installation',
|
|
44
|
-
ENTER_MORE: 'Do you want to enter another {0} for {1}',
|
|
45
|
-
FILTER_METRICS: 'Do you want metrics filtering?',
|
|
46
|
-
FILTERED_APIS: 'Enter APIs to filter metrics for',
|
|
47
|
-
ENTER_MORE_APIS: 'Do you want to add another API?',
|
|
48
|
-
ENVIRONMENT: 'Enter the Apigee Envirnoment to filter discovered APIs/metrics'
|
|
49
|
-
};
|
|
50
|
-
const askBundleType = async gateway => {
|
|
51
|
-
console.log(gateway);
|
|
52
|
-
if (gateway === _types.GatewayTypes.APIGEEX_GATEWAY) {
|
|
53
|
-
return await (0, _basicPrompts.askList)({
|
|
54
|
-
msg: helpers.agentMessages.selectAgentType,
|
|
55
|
-
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
return _types.BundleType.DISCOVERY;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
exports.askBundleType = askBundleType;
|
|
62
|
-
const askConfigType = async () => {
|
|
63
|
-
return _types.AgentConfigTypes.DOCKERIZED;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
// Questions for the configuration of Apigee X agents
|
|
68
|
-
//
|
|
69
|
-
exports.askConfigType = askConfigType;
|
|
70
|
-
const askApigeeXProjectId = async () => await (0, _basicPrompts.askInput)({
|
|
71
|
-
msg: ApigeeXPrompts.PROJECT_ID,
|
|
72
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.APIGEEXRegexPatterns.APIGEEX_REGEXP_PROJECT_ID, helpers.invalidValueExampleErrMsg('Project ID', 'rd-amplify-apigee-x'))
|
|
73
|
-
});
|
|
74
|
-
const askApigeeXDeveloperEmailAddress = async () => await (0, _basicPrompts.askInput)({
|
|
75
|
-
msg: ApigeeXPrompts.DEVELOPER_EMAIL_ADDRESS
|
|
76
|
-
});
|
|
77
|
-
const askApigeeXAuthFileName = async () => await (0, _basicPrompts.askInput)({
|
|
78
|
-
msg: ApigeeXPrompts.AUTH_FILE_NAME
|
|
79
|
-
});
|
|
80
|
-
const askApigeeXEnvironment = async () => await (0, _basicPrompts.askInput)({
|
|
81
|
-
msg: ApigeeXPrompts.ENVIRONMENT,
|
|
82
|
-
defaultValue: '',
|
|
83
|
-
allowEmptyInput: true
|
|
84
|
-
});
|
|
85
|
-
const askApigeeXMetricFilterConfig = async () => {
|
|
86
|
-
let filteredAPIs = [];
|
|
87
|
-
let filterMetricsEnabled = (await (0, _basicPrompts.askList)({
|
|
88
|
-
msg: ApigeeXPrompts.FILTER_METRICS,
|
|
89
|
-
default: _types.YesNo.No,
|
|
90
|
-
choices: _types.YesNoChoices
|
|
91
|
-
})) === _types.YesNo.Yes;
|
|
92
|
-
if (filterMetricsEnabled) {
|
|
93
|
-
let askFilteredAPIs = true;
|
|
94
|
-
console.log(_chalk.default.gray("An array of APIs to filter metrics for"));
|
|
95
|
-
while (askFilteredAPIs) {
|
|
96
|
-
const api = await (0, _basicPrompts.askInput)({
|
|
97
|
-
msg: ApigeeXPrompts.FILTERED_APIS,
|
|
98
|
-
allowEmptyInput: true
|
|
99
|
-
});
|
|
100
|
-
filteredAPIs.push(api);
|
|
101
|
-
askFilteredAPIs = (await (0, _basicPrompts.askList)({
|
|
102
|
-
msg: ApigeeXPrompts.ENTER_MORE_APIS,
|
|
103
|
-
default: _types.YesNo.No,
|
|
104
|
-
choices: _types.YesNoChoices
|
|
105
|
-
})) === _types.YesNo.Yes;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return new _types.ApigeeMetricsFilterConfig(filterMetricsEnabled, filteredAPIs);
|
|
109
|
-
};
|
|
110
|
-
const gatewayConnectivity = async installConfig => {
|
|
111
|
-
const apigeeXAgentValues = new _apigeexTemplates.ApigeeXAgentValues();
|
|
112
|
-
console.log('\nCONNECTION TO APIGEE X API GATEWAY:');
|
|
113
|
-
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.\n`));
|
|
114
|
-
|
|
115
|
-
// Apigee X Discovery Agent Prompts
|
|
116
|
-
if (installConfig.switches.isDaEnabled) {
|
|
117
|
-
console.log(_chalk.default.gray(`\nDiscovery Agent Configuration\n`));
|
|
118
|
-
await askDiscoveryPrompts(apigeeXAgentValues);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Apigee X Traceability Agent Prompts
|
|
122
|
-
if (installConfig.switches.isTaEnabled) {
|
|
123
|
-
console.log(_chalk.default.gray(`\nTraceability Agent Configuration\n`));
|
|
124
|
-
await askTraceabilityPrompts(apigeeXAgentValues);
|
|
125
|
-
}
|
|
126
|
-
return apigeeXAgentValues;
|
|
127
|
-
};
|
|
128
|
-
exports.gatewayConnectivity = gatewayConnectivity;
|
|
129
|
-
const generateSuccessHelpMsg = installConfig => {
|
|
130
|
-
if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
|
|
131
|
-
console.log(_chalk.default.yellow('\nPlease make sure to copy the "private_key.pem" and "public_key.pem" files for the existing service account you selected.'));
|
|
132
|
-
}
|
|
133
|
-
dockerSuccessMsg(installConfig);
|
|
134
|
-
console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.APIGEEX}`));
|
|
135
|
-
};
|
|
136
|
-
const dockerSuccessMsg = installConfig => {
|
|
137
|
-
let dockerInfo;
|
|
138
|
-
const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
|
|
139
|
-
const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
|
|
140
|
-
const runTaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
|
|
141
|
-
const runTaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
|
|
142
|
-
const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
|
|
143
|
-
const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
|
|
144
|
-
const startTaLinuxMsg = `\nStart the Traceability Agent on a Linux based machine`;
|
|
145
|
-
const startTaWinMsg = `\nStart the Traceability Agent on a Windows machine`;
|
|
146
|
-
if (installConfig.switches.isDaEnabled && installConfig.switches.isTaEnabled) {
|
|
147
|
-
dockerInfo = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${helpers.configFiles.DA_ENV_VARS} & ${helpers.configFiles.TA_ENV_VARS}):`;
|
|
148
|
-
} else if (installConfig.switches.isDaEnabled) {
|
|
149
|
-
dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
|
|
150
|
-
} else {
|
|
151
|
-
dockerInfo = `To utilize the traceability agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.TA_ENV_VARS}):`;
|
|
152
|
-
}
|
|
153
|
-
console.log(_chalk.default.whiteBright(dockerInfo), '\n');
|
|
154
|
-
if (installConfig.switches.isDaEnabled) {
|
|
155
|
-
const daImageVersion = `${daImage}:${installConfig.daVersion}`;
|
|
156
|
-
console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
|
|
157
|
-
console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
|
|
158
|
-
console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
|
|
159
|
-
console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
|
|
160
|
-
console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`), '\n');
|
|
161
|
-
}
|
|
162
|
-
if (installConfig.switches.isTaEnabled) {
|
|
163
|
-
const taImageVersion = `${taImage}:${installConfig.taVersion}`;
|
|
164
|
-
console.log(_chalk.default.white('Pull the latest image of the Traceability Agent:'));
|
|
165
|
-
console.log(_chalk.default.cyan(`docker pull ${taImageVersion}`));
|
|
166
|
-
console.log(_chalk.default.white(_utils.isWindows ? startTaWinMsg : startTaLinuxMsg));
|
|
167
|
-
console.log(_chalk.default.cyan(_utils.isWindows ? runTaWinMsg : runTaLinuxMsg));
|
|
168
|
-
console.log('\t', _chalk.default.cyan(`-v /data ${taImageVersion}`), '\n');
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// ApigeeX DA prompts
|
|
173
|
-
async function askDiscoveryPrompts(apigeeXAgentValues) {
|
|
174
|
-
// Apigee X ProjectId
|
|
175
|
-
apigeeXAgentValues.projectId = await askApigeeXProjectId();
|
|
176
|
-
// Apigee X Developer Email Address
|
|
177
|
-
apigeeXAgentValues.developerEmailAddress = await askApigeeXDeveloperEmailAddress();
|
|
178
|
-
// Apigee X Auth File Path
|
|
179
|
-
apigeeXAgentValues.fileName = await askApigeeXAuthFileName();
|
|
180
|
-
// Apigee X Environment
|
|
181
|
-
apigeeXAgentValues.environment = await askApigeeXEnvironment();
|
|
182
|
-
}
|
|
183
|
-
async function askTraceabilityPrompts(apigeeXAgentValues) {
|
|
184
|
-
// Apigee X Filter metrics
|
|
185
|
-
apigeeXAgentValues.metricsFilter = await askApigeeXMetricFilterConfig();
|
|
186
|
-
}
|
|
187
|
-
const completeInstall = async installConfig => {
|
|
188
|
-
/**
|
|
189
|
-
* Create agent resources
|
|
190
|
-
*/
|
|
191
|
-
const apigeeXAgentValues = installConfig.gatewayConfig;
|
|
192
|
-
|
|
193
|
-
// Add final settings to apigeeXAgentValues
|
|
194
|
-
apigeeXAgentValues.centralConfig = installConfig.centralConfig;
|
|
195
|
-
apigeeXAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
|
|
196
|
-
console.log('Generating the configuration file(s)...');
|
|
197
|
-
if (installConfig.switches.isDaEnabled) {
|
|
198
|
-
(0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, apigeeXAgentValues, helpers.apigeeXDAEnvVarTemplate);
|
|
199
|
-
}
|
|
200
|
-
if (installConfig.switches.isTaEnabled) {
|
|
201
|
-
(0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, apigeeXAgentValues, helpers.apigeeXTAEnvVarTemplate);
|
|
202
|
-
}
|
|
203
|
-
console.log('Configuration file(s) have been successfully created.\n');
|
|
204
|
-
generateSuccessHelpMsg(installConfig);
|
|
205
|
-
};
|
|
206
|
-
exports.completeInstall = completeInstall;
|
|
207
|
-
const ApigeeXInstallMethods = exports.ApigeeXInstallMethods = {
|
|
208
|
-
GetBundleType: askBundleType,
|
|
209
|
-
GetDeploymentType: askConfigType,
|
|
210
|
-
AskGatewayQuestions: gatewayConnectivity,
|
|
211
|
-
FinalizeGatewayInstall: completeInstall,
|
|
212
|
-
ConfigFiles: Object.values(ConfigFiles),
|
|
213
|
-
AgentNameMap: {
|
|
214
|
-
[_types.AgentTypes.da]: _types.AgentNames.APIGEEX_DA,
|
|
215
|
-
[_types.AgentTypes.ta]: _types.AgentNames.APIGEEX_TA
|
|
216
|
-
},
|
|
217
|
-
GatewayDisplay: _types.GatewayTypes.APIGEEX_GATEWAY
|
|
218
|
-
};
|
|
219
|
-
const testables = exports.testables = {
|
|
220
|
-
ApigeeXPrompts,
|
|
221
|
-
ConfigFiles,
|
|
222
|
-
defaultLogFiles
|
|
223
|
-
};
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.testables = exports.askBundleType = exports.APIGEEXSaaSInstallMethods = void 0;
|
|
7
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
|
-
var _basicPrompts = require("../../common/basicPrompts");
|
|
10
|
-
var _types = require("../../common/types");
|
|
11
|
-
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
12
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
-
const {
|
|
19
|
-
log
|
|
20
|
-
} = (0, _snooplogg.default)('engage: install: agents: saas');
|
|
21
|
-
class DataplaneConfig {
|
|
22
|
-
constructor(type) {
|
|
23
|
-
_defineProperty(this, "type", void 0);
|
|
24
|
-
this.type = type || "";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
class APIGEEXDataplaneConfig extends DataplaneConfig {
|
|
28
|
-
constructor(projectID, developerEmail, mode, metricsFilter, environment) {
|
|
29
|
-
super("Apigee X");
|
|
30
|
-
_defineProperty(this, "projectId", void 0);
|
|
31
|
-
_defineProperty(this, "developerEmail", void 0);
|
|
32
|
-
_defineProperty(this, "mode", void 0);
|
|
33
|
-
_defineProperty(this, "metricsFilter", void 0);
|
|
34
|
-
_defineProperty(this, "environment", void 0);
|
|
35
|
-
this.projectId = projectID;
|
|
36
|
-
this.developerEmail = developerEmail;
|
|
37
|
-
this.mode = mode;
|
|
38
|
-
this.metricsFilter = metricsFilter;
|
|
39
|
-
this.environment = environment;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class SaasAgentValues {
|
|
43
|
-
constructor() {
|
|
44
|
-
_defineProperty(this, "frequencyDA", void 0);
|
|
45
|
-
_defineProperty(this, "queueDA", void 0);
|
|
46
|
-
_defineProperty(this, "frequencyTA", void 0);
|
|
47
|
-
_defineProperty(this, "dataplaneConfig", void 0);
|
|
48
|
-
_defineProperty(this, "centralConfig", void 0);
|
|
49
|
-
this.frequencyDA = '';
|
|
50
|
-
this.queueDA = false;
|
|
51
|
-
this.frequencyTA = '';
|
|
52
|
-
this.dataplaneConfig = new DataplaneConfig();
|
|
53
|
-
this.centralConfig = new _types.CentralAgentConfig();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
class SaasAPIGEEXAgentValues extends SaasAgentValues {
|
|
57
|
-
constructor() {
|
|
58
|
-
super();
|
|
59
|
-
_defineProperty(this, "authType", void 0);
|
|
60
|
-
_defineProperty(this, "clientEmailAddress", void 0);
|
|
61
|
-
_defineProperty(this, "credentialJSON", void 0);
|
|
62
|
-
_defineProperty(this, "projectId", void 0);
|
|
63
|
-
_defineProperty(this, "developerEmailAddress", void 0);
|
|
64
|
-
_defineProperty(this, "mode", void 0);
|
|
65
|
-
_defineProperty(this, "metricsFilter", void 0);
|
|
66
|
-
_defineProperty(this, "environment", void 0);
|
|
67
|
-
this.authType = _types.APIGEEXAuthType.IMP_SVC_ACC;
|
|
68
|
-
this.clientEmailAddress = '';
|
|
69
|
-
this.credentialJSON = '';
|
|
70
|
-
this.projectId = '';
|
|
71
|
-
this.developerEmailAddress = '';
|
|
72
|
-
this.mode = _types.APIGEEXDISCOVERYMODES.PROXY;
|
|
73
|
-
this.metricsFilter = new _types.ApigeeMetricsFilterConfig(true, []);
|
|
74
|
-
this.environment = '';
|
|
75
|
-
}
|
|
76
|
-
getAccessData() {
|
|
77
|
-
let data = JSON.stringify({
|
|
78
|
-
client_email: this.clientEmailAddress
|
|
79
|
-
});
|
|
80
|
-
if (this.authType == _types.APIGEEXAuthType.ACCESS_CREDENTIAL) {
|
|
81
|
-
data = JSON.stringify(this.credentialJSON);
|
|
82
|
-
}
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ConfigFiles - all the config file that are used in the setup
|
|
88
|
-
const ConfigFiles = {};
|
|
89
|
-
|
|
90
|
-
// APIGEEX SaaSPrompts - all APIGEEX Saas prompts to the user for input
|
|
91
|
-
const SaasPrompts = {
|
|
92
|
-
AUTHENTICATION_TYPE: 'Authenticate with an Impersonation of a Service Account or by providing a Credential File',
|
|
93
|
-
PROJECT_ID: 'Enter the APIGEE X Project ID the agent will use',
|
|
94
|
-
DEVELOPER_EMAIL_ADDRESS: 'Enter the APIGEE X Developer Email Address the agent will use',
|
|
95
|
-
CLIENT_EMAIL_ADDRESS: 'Enter the Client Email Address the agent will use for the APIGEE X Service Account',
|
|
96
|
-
UPLOAD_CREDENTIAL_FILE: 'Upload a JSON Credential file to be used for APIGEE X Authentication',
|
|
97
|
-
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
98
|
-
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
99
|
-
QUEUE: 'Do you want to discover immediately after installation',
|
|
100
|
-
ENTER_MORE: 'Do you want to enter another {0} for {1}',
|
|
101
|
-
FILTER_METRICS: 'Do you want metrics filtering? (defaults to true)',
|
|
102
|
-
FILTERED_APIS: 'Enter APIs to filter metrics for',
|
|
103
|
-
ENTER_MORE_APIS: 'Do you want to add another API?',
|
|
104
|
-
ENVIRONMENT: 'Enter the Apigee Environment to filter discovered APIs/metrics'
|
|
105
|
-
};
|
|
106
|
-
const askBundleType = async () => {
|
|
107
|
-
return await (0, _basicPrompts.askList)({
|
|
108
|
-
msg: helpers.agentMessages.selectAgentType,
|
|
109
|
-
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
exports.askBundleType = askBundleType;
|
|
113
|
-
const askConfigType = async () => {
|
|
114
|
-
return _types.AgentConfigTypes.HOSTED;
|
|
115
|
-
};
|
|
116
|
-
const askForAPIGEEXCredentials = async hostedAgentValues => {
|
|
117
|
-
log("gathering access details for apigee x");
|
|
118
|
-
hostedAgentValues.projectId = await (0, _basicPrompts.askInput)({
|
|
119
|
-
msg: SaasPrompts.PROJECT_ID,
|
|
120
|
-
defaultValue: hostedAgentValues.projectId !== '' ? hostedAgentValues.projectId : undefined,
|
|
121
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.APIGEEXRegexPatterns.APIGEEX_REGEXP_PROJECT_ID, helpers.invalidValueExampleErrMsg('Project ID', 'rd-amplify-apigee-x'))
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// get developer email address
|
|
125
|
-
hostedAgentValues.developerEmailAddress = await (0, _basicPrompts.askInput)({
|
|
126
|
-
msg: SaasPrompts.DEVELOPER_EMAIL_ADDRESS,
|
|
127
|
-
defaultValue: hostedAgentValues.developerEmailAddress !== '' ? hostedAgentValues.developerEmailAddress : undefined,
|
|
128
|
-
allowEmptyInput: true
|
|
129
|
-
});
|
|
130
|
-
hostedAgentValues.authType = _types.APIGEEXAuthType.IMP_SVC_ACC;
|
|
131
|
-
console.log(_chalk.default.gray("Please refer to docs.axway.com for information on creating the necessary APIGEE X IAM policies"));
|
|
132
|
-
if (hostedAgentValues.authType === _types.APIGEEXAuthType.IMP_SVC_ACC) {
|
|
133
|
-
log("using impersonate service account authentication");
|
|
134
|
-
// get client email address
|
|
135
|
-
hostedAgentValues.clientEmailAddress = await (0, _basicPrompts.askInput)({
|
|
136
|
-
msg: SaasPrompts.CLIENT_EMAIL_ADDRESS,
|
|
137
|
-
defaultValue: hostedAgentValues.clientEmailAddress !== '' ? hostedAgentValues.clientEmailAddress : undefined,
|
|
138
|
-
allowEmptyInput: true
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
hostedAgentValues.metricsFilter.filterMetrics = (await (0, _basicPrompts.askList)({
|
|
142
|
-
msg: SaasPrompts.FILTER_METRICS,
|
|
143
|
-
default: _types.YesNo.No,
|
|
144
|
-
choices: _types.YesNoChoices
|
|
145
|
-
})) === _types.YesNo.Yes;
|
|
146
|
-
if (hostedAgentValues.metricsFilter.filterMetrics) {
|
|
147
|
-
let askFilteredAPIs = true;
|
|
148
|
-
console.log(_chalk.default.gray("An array of APIs to filter metrics for"));
|
|
149
|
-
while (askFilteredAPIs) {
|
|
150
|
-
const api = await (0, _basicPrompts.askInput)({
|
|
151
|
-
msg: SaasPrompts.FILTERED_APIS,
|
|
152
|
-
allowEmptyInput: true
|
|
153
|
-
});
|
|
154
|
-
hostedAgentValues.metricsFilter.filteredAPIs.push(api);
|
|
155
|
-
askFilteredAPIs = (await (0, _basicPrompts.askList)({
|
|
156
|
-
msg: SaasPrompts.ENTER_MORE_APIS,
|
|
157
|
-
default: _types.YesNo.No,
|
|
158
|
-
choices: _types.YesNoChoices
|
|
159
|
-
})) === _types.YesNo.Yes;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
hostedAgentValues.environment = await (0, _basicPrompts.askInput)({
|
|
163
|
-
msg: SaasPrompts.ENVIRONMENT,
|
|
164
|
-
defaultValue: '',
|
|
165
|
-
allowEmptyInput: true
|
|
166
|
-
});
|
|
167
|
-
return hostedAgentValues;
|
|
168
|
-
};
|
|
169
|
-
const validateFrequency = () => input => {
|
|
170
|
-
let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
|
|
171
|
-
if (typeof val === "string") {
|
|
172
|
-
return val;
|
|
173
|
-
}
|
|
174
|
-
let r = input.toString().match(/^(\d*)m/);
|
|
175
|
-
if (r) {
|
|
176
|
-
// only minutes
|
|
177
|
-
let mins = r[1];
|
|
178
|
-
if (parseInt(mins, 10) < 30) {
|
|
179
|
-
return "Minimum frequency is 30m";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return true;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// @ts-ignore
|
|
186
|
-
const gatewayConnectivity = async installConfig => {
|
|
187
|
-
console.log('\nCONNECTION TO APIGEE X API GATEWAY:');
|
|
188
|
-
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 Engage"));
|
|
189
|
-
|
|
190
|
-
// DeploymentType
|
|
191
|
-
let hostedAgentValues = new SaasAgentValues();
|
|
192
|
-
if (installConfig.gatewayType === _types.SaaSGatewayTypes.APIGEEX_GATEWAY) {
|
|
193
|
-
// APIGEE X connection details
|
|
194
|
-
hostedAgentValues = new SaasAPIGEEXAgentValues();
|
|
195
|
-
hostedAgentValues = await askForAPIGEEXCredentials(hostedAgentValues);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Ask to queue discovery now
|
|
199
|
-
log("getting the frequency and if the agent should run now");
|
|
200
|
-
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."));
|
|
201
|
-
hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
|
|
202
|
-
msg: SaasPrompts.DA_FREQUENCY,
|
|
203
|
-
validate: validateFrequency(),
|
|
204
|
-
allowEmptyInput: true
|
|
205
|
-
});
|
|
206
|
-
hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
|
|
207
|
-
msg: SaasPrompts.QUEUE,
|
|
208
|
-
default: _types.YesNo.No,
|
|
209
|
-
choices: _types.YesNoChoices
|
|
210
|
-
})) === _types.YesNo.Yes;
|
|
211
|
-
if (installConfig.switches.isTaEnabled) {
|
|
212
|
-
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."));
|
|
213
|
-
hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
|
|
214
|
-
msg: SaasPrompts.TA_FREQUENCY,
|
|
215
|
-
defaultValue: "30m",
|
|
216
|
-
validate: validateFrequency(),
|
|
217
|
-
allowEmptyInput: true
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
return hostedAgentValues;
|
|
221
|
-
};
|
|
222
|
-
const generateOutput = async installConfig => {
|
|
223
|
-
return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
|
|
224
|
-
};
|
|
225
|
-
const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
|
|
226
|
-
var _dataplaneRes$securit, _dataplaneRes$securit2;
|
|
227
|
-
// grab key from data plane resource
|
|
228
|
-
let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
|
|
229
|
-
let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
|
|
230
|
-
if (key === "" || hash === "") {
|
|
231
|
-
throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
|
|
232
|
-
}
|
|
233
|
-
let encData = _crypto.default.publicEncrypt({
|
|
234
|
-
key: key,
|
|
235
|
-
padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
|
|
236
|
-
oaepHash: hash
|
|
237
|
-
}, Buffer.from(hostedAgentValues.getAccessData()));
|
|
238
|
-
return encData.toString("base64");
|
|
239
|
-
};
|
|
240
|
-
const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
241
|
-
/**
|
|
242
|
-
* Create agent resources
|
|
243
|
-
*/
|
|
244
|
-
console.log("\n");
|
|
245
|
-
let apigeeXAgentValues = installConfig.gatewayConfig;
|
|
246
|
-
|
|
247
|
-
// create the environment, if necessary
|
|
248
|
-
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
249
|
-
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
250
|
-
production: installConfig.centralConfig.production
|
|
251
|
-
}) : installConfig.centralConfig.ampcEnvInfo.name;
|
|
252
|
-
if (installConfig.gatewayType === _types.SaaSGatewayTypes.APIGEEX_GATEWAY) {
|
|
253
|
-
apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.projectId, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode, apigeeXAgentValues.metricsFilter, apigeeXAgentValues.environment);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// create the data plane resource
|
|
257
|
-
let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], apigeeXAgentValues.dataplaneConfig);
|
|
258
|
-
// create data plane secret resource
|
|
259
|
-
try {
|
|
260
|
-
await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(apigeeXAgentValues, dataplaneRes));
|
|
261
|
-
} catch (error) {
|
|
262
|
-
console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
|
|
263
|
-
if (installConfig.centralConfig.ampcEnvInfo.isNew) {
|
|
264
|
-
await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
265
|
-
} else {
|
|
266
|
-
await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
|
|
267
|
-
}
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// create discovery agent resource
|
|
272
|
-
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);
|
|
273
|
-
if (installConfig.switches.isTaEnabled) {
|
|
274
|
-
// create traceability agent resource
|
|
275
|
-
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
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
console.log(await generateOutput(installConfig));
|
|
279
|
-
};
|
|
280
|
-
const APIGEEXSaaSInstallMethods = exports.APIGEEXSaaSInstallMethods = {
|
|
281
|
-
GetBundleType: askBundleType,
|
|
282
|
-
GetDeploymentType: askConfigType,
|
|
283
|
-
AskGatewayQuestions: gatewayConnectivity,
|
|
284
|
-
FinalizeGatewayInstall: completeInstall,
|
|
285
|
-
ConfigFiles: [],
|
|
286
|
-
AgentNameMap: {
|
|
287
|
-
[_types.AgentTypes.da]: _types.AgentNames.APIGEEX_DA,
|
|
288
|
-
[_types.AgentTypes.ta]: _types.AgentNames.APIGEEX_TA
|
|
289
|
-
},
|
|
290
|
-
GatewayDisplay: _types.SaaSGatewayTypes.APIGEEX_GATEWAY
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
// These are the items that are not exported, but need to be for testing
|
|
294
|
-
const testables = exports.testables = {
|
|
295
|
-
SaasAgentValues,
|
|
296
|
-
SaasAPIGEEXAgentValues,
|
|
297
|
-
APIGEEXAuthType: _types.APIGEEXAuthType,
|
|
298
|
-
SaasPrompts,
|
|
299
|
-
ConfigFiles
|
|
300
|
-
};
|