@axway/axway-central-cli 2.27.0 → 2.28.0-rc.1
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 +3 -1
- package/dist/commands/install/apigeexSaasAgents.js +49 -3
- package/dist/commands/install/edgeAgents.js +3 -2
- package/dist/commands/install/graylogAgent.js +142 -0
- package/dist/commands/install/helpers/creators.js +48 -8
- package/dist/commands/install/helpers/index.js +14 -1
- package/dist/commands/install/helpers/inputs.js +52 -2
- package/dist/commands/install/helpers/templates/edgeTemplates.js +7 -4
- package/dist/commands/install/helpers/templates/graylogTemplates.js +70 -0
- package/dist/commands/install/istioAgents.js +1 -1
- package/dist/commands/install/platform.js +23 -2
- package/dist/common/ApiServerClient.js +52 -0
- package/dist/common/types.js +9 -1
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ var istioAgents = _interopRequireWildcard(require("./istioAgents"));
|
|
|
27
27
|
var azureSaasAgents = _interopRequireWildcard(require("./azureSaasAgents"));
|
|
28
28
|
var kafkaAgents = _interopRequireWildcard(require("./kafkaAgents"));
|
|
29
29
|
var swaggerHubAgents = _interopRequireWildcard(require("./swaggerHubSaasAgents"));
|
|
30
|
+
var graylogAgent = _interopRequireWildcard(require("./graylogAgent"));
|
|
30
31
|
var platform = _interopRequireWildcard(require("./platform"));
|
|
31
32
|
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); }
|
|
32
33
|
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; }
|
|
@@ -46,7 +47,8 @@ const agentInstallFlows = {
|
|
|
46
47
|
[_types.GatewayTypes.GITLAB]: gitLabAgents.GitLabInstallMethods,
|
|
47
48
|
[_types.GatewayTypes.AZURE_GATEWAY]: azureAgents.AzureInstallMethods,
|
|
48
49
|
[_types.GatewayTypes.ISTIO]: istioAgents.IstioInstallMethods,
|
|
49
|
-
[_types.GatewayTypes.KAFKA]: kafkaAgents.KafkaInstallMethods
|
|
50
|
+
[_types.GatewayTypes.KAFKA]: kafkaAgents.KafkaInstallMethods,
|
|
51
|
+
[_types.GatewayTypes.GRAYLOG]: graylogAgent.GraylogInstallMethods
|
|
50
52
|
};
|
|
51
53
|
const saasAgentInstallFlows = {
|
|
52
54
|
[_types.SaaSGatewayTypes.AWS_GATEWAY]: awsSaaSAgents.AWSSaaSInstallMethods,
|
|
@@ -26,14 +26,26 @@ class DataplaneConfig {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
class APIGEEXDataplaneConfig extends DataplaneConfig {
|
|
29
|
-
constructor(projectID, developerEmail, mode) {
|
|
29
|
+
constructor(projectID, developerEmail, mode, metricsFilter, environment) {
|
|
30
30
|
super("Apigee");
|
|
31
31
|
_defineProperty(this, "projectId", void 0);
|
|
32
32
|
_defineProperty(this, "developerEmail", void 0);
|
|
33
33
|
_defineProperty(this, "mode", void 0);
|
|
34
|
+
_defineProperty(this, "metricsFilter", void 0);
|
|
35
|
+
_defineProperty(this, "environment", void 0);
|
|
34
36
|
this.projectId = projectID;
|
|
35
37
|
this.developerEmail = developerEmail;
|
|
36
38
|
this.mode = mode;
|
|
39
|
+
this.metricsFilter = metricsFilter;
|
|
40
|
+
this.environment = environment;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
class ApigeeMetricsFilterConfig {
|
|
44
|
+
constructor(filterMetrics, filteredAPIs) {
|
|
45
|
+
_defineProperty(this, "filterMetrics", void 0);
|
|
46
|
+
_defineProperty(this, "filteredAPIs", void 0);
|
|
47
|
+
this.filterMetrics = filterMetrics;
|
|
48
|
+
this.filteredAPIs = filteredAPIs;
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
51
|
class SaasAgentValues {
|
|
@@ -59,12 +71,16 @@ class SaasAPIGEEXAgentValues extends SaasAgentValues {
|
|
|
59
71
|
_defineProperty(this, "projectId", void 0);
|
|
60
72
|
_defineProperty(this, "developerEmailAddress", void 0);
|
|
61
73
|
_defineProperty(this, "mode", void 0);
|
|
74
|
+
_defineProperty(this, "metricsFilter", void 0);
|
|
75
|
+
_defineProperty(this, "environment", void 0);
|
|
62
76
|
this.authType = APIGEEXAuthType.IMP_SVC_ACC;
|
|
63
77
|
this.clientEmailAddress = '';
|
|
64
78
|
this.credentialJSON = '';
|
|
65
79
|
this.projectId = '';
|
|
66
80
|
this.developerEmailAddress = '';
|
|
67
81
|
this.mode = _types.APIGEEXDISCOVERYMODES.PROXY;
|
|
82
|
+
this.metricsFilter = new ApigeeMetricsFilterConfig(true, []);
|
|
83
|
+
this.environment = '';
|
|
68
84
|
}
|
|
69
85
|
getAccessData() {
|
|
70
86
|
let data = JSON.stringify({
|
|
@@ -95,7 +111,11 @@ const SaasPrompts = {
|
|
|
95
111
|
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
96
112
|
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
97
113
|
QUEUE: 'Do you want to discover immediately after installation',
|
|
98
|
-
ENTER_MORE: 'Do you want to enter another {0} for {1}'
|
|
114
|
+
ENTER_MORE: 'Do you want to enter another {0} for {1}',
|
|
115
|
+
FILTER_METRICS: 'Do you want metrics filtering? (defaults to true)',
|
|
116
|
+
FILTERED_APIS: 'Enter APIs to filter metrics for',
|
|
117
|
+
ENTER_MORE_APIS: 'Do you want to add another API?',
|
|
118
|
+
ENVIRONMENT: 'Enter the Apigee Envirnoment to filter discovered APIs/metrics'
|
|
99
119
|
};
|
|
100
120
|
const askBundleType = async () => {
|
|
101
121
|
return await (0, _basicPrompts.askList)({
|
|
@@ -132,6 +152,32 @@ const askForAPIGEEXCredentials = async hostedAgentValues => {
|
|
|
132
152
|
allowEmptyInput: true
|
|
133
153
|
});
|
|
134
154
|
}
|
|
155
|
+
hostedAgentValues.metricsFilter.filterMetrics = (await (0, _basicPrompts.askList)({
|
|
156
|
+
msg: SaasPrompts.FILTER_METRICS,
|
|
157
|
+
default: _types.YesNo.No,
|
|
158
|
+
choices: _types.YesNoChoices
|
|
159
|
+
})) === _types.YesNo.Yes;
|
|
160
|
+
if (hostedAgentValues.metricsFilter.filterMetrics) {
|
|
161
|
+
let askFilteredAPIs = true;
|
|
162
|
+
console.log(_chalk.default.gray("An array of APIs to filter metrics for"));
|
|
163
|
+
while (askFilteredAPIs) {
|
|
164
|
+
const api = await (0, _basicPrompts.askInput)({
|
|
165
|
+
msg: SaasPrompts.FILTERED_APIS,
|
|
166
|
+
allowEmptyInput: true
|
|
167
|
+
});
|
|
168
|
+
hostedAgentValues.metricsFilter.filteredAPIs.push(api);
|
|
169
|
+
askFilteredAPIs = (await (0, _basicPrompts.askList)({
|
|
170
|
+
msg: SaasPrompts.ENTER_MORE_APIS,
|
|
171
|
+
default: _types.YesNo.No,
|
|
172
|
+
choices: _types.YesNoChoices
|
|
173
|
+
})) === _types.YesNo.Yes;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
hostedAgentValues.environment = await (0, _basicPrompts.askInput)({
|
|
177
|
+
msg: SaasPrompts.ENVIRONMENT,
|
|
178
|
+
defaultValue: '',
|
|
179
|
+
allowEmptyInput: true
|
|
180
|
+
});
|
|
135
181
|
return hostedAgentValues;
|
|
136
182
|
};
|
|
137
183
|
const validateFrequency = () => input => {
|
|
@@ -218,7 +264,7 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
|
218
264
|
production: installConfig.centralConfig.production
|
|
219
265
|
}) : installConfig.centralConfig.ampcEnvInfo.name;
|
|
220
266
|
if (installConfig.gatewayType === _types.SaaSGatewayTypes.APIGEEX_GATEWAY) {
|
|
221
|
-
apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.projectId, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode);
|
|
267
|
+
apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.projectId, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode, apigeeXAgentValues.metricsFilter, apigeeXAgentValues.environment);
|
|
222
268
|
}
|
|
223
269
|
|
|
224
270
|
// create the data plane resource
|
|
@@ -191,7 +191,7 @@ const gatewayConnectivity = async installConfig => {
|
|
|
191
191
|
}
|
|
192
192
|
if (installConfig.switches.isTaEnabled) {
|
|
193
193
|
v7AgentValues.isOpenTraffic = await askLoggingSource();
|
|
194
|
-
if (!v7AgentValues.isOpenTraffic) {
|
|
194
|
+
if (!v7AgentValues.isOpenTraffic && installConfig.bundleType !== _types.BundleType.TRACEABILITY_OFFLINE) {
|
|
195
195
|
console.log('\nCONNECTION TO API GATEWAY:');
|
|
196
196
|
console.log(_cliKit.chalk.gray(`The traceability agent needs to connect to Axway API Gateway.\n` + `Use the credentials of an Operator user.`));
|
|
197
197
|
if (installConfig.switches.isHelmInstall) {
|
|
@@ -365,8 +365,9 @@ const helmSuccessMsg = (namespace, isDaEnabled, isTaEnabled) => {
|
|
|
365
365
|
finishUp += `helm upgrade --install --namespace ${namespace} v7-traceability axway/v7-traceability -f ${ConfigFiles.TAHelmOverride}`;
|
|
366
366
|
}
|
|
367
367
|
console.log(_cliKit.chalk.white('\nTo deploy the Agents run the following commands\n'));
|
|
368
|
-
console.log(_cliKit.chalk.cyan('helm repo add axway https://
|
|
368
|
+
console.log(_cliKit.chalk.cyan('helm repo add axway https://helm.repository.axway.com --username=<client_id> --password=<client_secret>'));
|
|
369
369
|
console.log(_cliKit.chalk.cyan(finishUp));
|
|
370
|
+
console.log(_cliKit.chalk.white(`\n* client_id - service account id for your Amplify Platform organization`), _cliKit.chalk.white(`\n* client_secret - service account secret for your Amplify Platform organization`));
|
|
370
371
|
};
|
|
371
372
|
const edgeAgentNameMap = {
|
|
372
373
|
[_types.AgentTypes.da]: _types.AgentNames.EDGE_DA,
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.testables = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.GraylogInstallMethods = exports.ConfigFiles = void 0;
|
|
7
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
+
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
|
+
var _Kubectl = require("../../common/Kubectl");
|
|
10
|
+
var _basicPrompts = require("../../common/basicPrompts");
|
|
11
|
+
var _inputs = require("./helpers/inputs");
|
|
12
|
+
var _types = require("../../common/types");
|
|
13
|
+
var _utils = require("../../common/utils");
|
|
14
|
+
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
15
|
+
var _graylogTemplates = require("./helpers/templates/graylogTemplates");
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const {
|
|
21
|
+
log
|
|
22
|
+
} = (0, _snooplogg.default)('central: install: agents: graylog');
|
|
23
|
+
const amplifyAgentsNs = exports.amplifyAgentsNs = 'amplify-agents';
|
|
24
|
+
|
|
25
|
+
// ConfigFiles - all the config file that are used in the setup
|
|
26
|
+
const ConfigFiles = exports.ConfigFiles = {
|
|
27
|
+
helmOverride: 'agent-overrides.yaml'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// GraylogPrompts - prompts for user inputs
|
|
31
|
+
const prompts = {
|
|
32
|
+
agentNamespace: 'Enter the namespace to use for the Amplify Graylog Agents',
|
|
33
|
+
enterUrl: 'Enter the Graylog base URL that the agent will use',
|
|
34
|
+
enterUsername: 'Enter the Graylog user name',
|
|
35
|
+
enterPassword: 'Enter the password for Graylog user',
|
|
36
|
+
enterBasePathSegmentLen: 'Enter the base path segment length that agent will use for lookup'
|
|
37
|
+
};
|
|
38
|
+
const askBundleType = async () => {
|
|
39
|
+
return _types.BundleType.TRACEABILITY;
|
|
40
|
+
};
|
|
41
|
+
exports.askBundleType = askBundleType;
|
|
42
|
+
const askConfigType = async () => {
|
|
43
|
+
return _types.AgentConfigTypes.HELM;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//
|
|
47
|
+
// Questions for the configuration of Graylog agent
|
|
48
|
+
//
|
|
49
|
+
exports.askConfigType = askConfigType;
|
|
50
|
+
const askURL = async () => await (0, _basicPrompts.askInput)({
|
|
51
|
+
msg: prompts.enterUrl,
|
|
52
|
+
allowEmptyInput: false,
|
|
53
|
+
validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabBaseURLRegex, helpers.invalidValueExampleErrMsg('BaseURL', 'https://www.testdomain.com'))
|
|
54
|
+
});
|
|
55
|
+
const askUsername = async () => await (0, _basicPrompts.askInput)({
|
|
56
|
+
msg: prompts.enterUsername,
|
|
57
|
+
allowEmptyInput: false
|
|
58
|
+
});
|
|
59
|
+
const askPassword = async () => await (0, _basicPrompts.askInput)({
|
|
60
|
+
msg: prompts.enterPassword
|
|
61
|
+
});
|
|
62
|
+
const askBasePathSegmentLen = async () => await (0, _basicPrompts.askInput)({
|
|
63
|
+
msg: prompts.enterBasePathSegmentLen,
|
|
64
|
+
type: 'number',
|
|
65
|
+
defaultValue: 2
|
|
66
|
+
});
|
|
67
|
+
const gatewayConnectivity = async _installConfig => {
|
|
68
|
+
console.log(_chalk.default.gray(`The Amplify Graylog Agent needs to be deployed to your Kubernetes cluster to discover APIs for publishing to Amplify Central.`));
|
|
69
|
+
const {
|
|
70
|
+
error
|
|
71
|
+
} = await _Kubectl.kubectl.isInstalled();
|
|
72
|
+
if (error) {
|
|
73
|
+
throw new Error(`Kubectl is required to fill out the following prompts. It appears to be missing or misconfigured.\n${error}`);
|
|
74
|
+
}
|
|
75
|
+
const graylogAgentValues = new _graylogTemplates.GraylogAgentValues();
|
|
76
|
+
graylogAgentValues.namespace = await (0, _inputs.askNamespace)(prompts.agentNamespace, amplifyAgentsNs);
|
|
77
|
+
graylogAgentValues.url = await askURL();
|
|
78
|
+
graylogAgentValues.userName = await askUsername();
|
|
79
|
+
graylogAgentValues.password = await askPassword();
|
|
80
|
+
graylogAgentValues.basePathSegmentLen = await askBasePathSegmentLen();
|
|
81
|
+
return graylogAgentValues;
|
|
82
|
+
};
|
|
83
|
+
exports.gatewayConnectivity = gatewayConnectivity;
|
|
84
|
+
const generateSuccessHelpMsg = graylogAgentValues => {
|
|
85
|
+
console.log(`Graylog Agent override file has been placed at ${process.cwd()}/${ConfigFiles.helmOverride}`);
|
|
86
|
+
const installCmd = `helm upgrade --install --namespace ${graylogAgentValues.namespace.name} graylog-agent axway/graylog-agent -f ${ConfigFiles.helmOverride}`;
|
|
87
|
+
console.log('To complete the Graylog Agent installation run the following commands:', _chalk.default.cyan('\n helm repo add axway https://helm.repository.axway.com --username=<client_id> --password=<client_secret>'), _chalk.default.cyan(`\n helm repo update\n ${installCmd}`), _chalk.default.cyan(`\n`), _chalk.default.white(`\n* client_id - service account id for your Amplify Platform organization`), _chalk.default.white(`\n* client_secret - service account secret for your Amplify Platform organization`));
|
|
88
|
+
console.log('Configuration file(s) have been successfully created.\n');
|
|
89
|
+
console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.GRAYLOG}`));
|
|
90
|
+
};
|
|
91
|
+
const completeInstall = async installConfig => {
|
|
92
|
+
// Add final settings to graylogAgentValues
|
|
93
|
+
const graylogAgentValues = installConfig.gatewayConfig;
|
|
94
|
+
if (graylogAgentValues.namespace.isNew) {
|
|
95
|
+
await helpers.createNamespace(graylogAgentValues.namespace.name);
|
|
96
|
+
}
|
|
97
|
+
graylogAgentValues.centralConfig = installConfig.centralConfig;
|
|
98
|
+
graylogAgentValues.graylogSecret = helpers.amplifyAgentsCredsSecret;
|
|
99
|
+
graylogAgentValues.agentKeysSecret = helpers.amplifyAgentsKeysSecret;
|
|
100
|
+
// read file content
|
|
101
|
+
await helpers.createSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, async () => {
|
|
102
|
+
if (installConfig.centralConfig.ampcDosaInfo.isNew) {
|
|
103
|
+
console.log(_chalk.default.yellow(`The secret '${helpers.amplifyAgentsKeysSecret}' will be created with the same "private_key.pem" and "public_key.pem" that was auto generated to create the Service Account.`));
|
|
104
|
+
}
|
|
105
|
+
await helpers.createAmplifyAgentKeysSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, 'publicKey', graylogAgentValues.centralConfig.dosaAccount.publicKey, 'privateKey', graylogAgentValues.centralConfig.dosaAccount.privateKey);
|
|
106
|
+
});
|
|
107
|
+
await helpers.createSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, async () => {
|
|
108
|
+
await createGraylogCredsSecret(graylogAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, graylogAgentValues.userName, graylogAgentValues.password);
|
|
109
|
+
});
|
|
110
|
+
graylogAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
|
|
111
|
+
console.log('Generating the configuration file(s)...');
|
|
112
|
+
(0, _utils.writeTemplates)(ConfigFiles.helmOverride, graylogAgentValues, helpers.graylogHelmOverrideTemplate);
|
|
113
|
+
generateSuccessHelpMsg(graylogAgentValues);
|
|
114
|
+
};
|
|
115
|
+
exports.completeInstall = completeInstall;
|
|
116
|
+
const createGraylogCredsSecret = async (namespace, secretName, user, password) => {
|
|
117
|
+
const {
|
|
118
|
+
error
|
|
119
|
+
} = await _Kubectl.kubectl.create('secret', `-n ${namespace} generic ${secretName} \
|
|
120
|
+
--from-literal=username=${user} \
|
|
121
|
+
--from-literal=password=${password}`);
|
|
122
|
+
if (error) {
|
|
123
|
+
throw Error(error);
|
|
124
|
+
}
|
|
125
|
+
console.log(`Created ${secretName} in the ${namespace} namespace.`);
|
|
126
|
+
};
|
|
127
|
+
const GraylogInstallMethods = exports.GraylogInstallMethods = {
|
|
128
|
+
GetBundleType: askBundleType,
|
|
129
|
+
GetDeploymentType: askConfigType,
|
|
130
|
+
AskGatewayQuestions: gatewayConnectivity,
|
|
131
|
+
FinalizeGatewayInstall: completeInstall,
|
|
132
|
+
ConfigFiles: Object.values(ConfigFiles),
|
|
133
|
+
AgentNameMap: {
|
|
134
|
+
[_types.AgentTypes.da]: _types.AgentNames.GRAYLOG_TA,
|
|
135
|
+
[_types.AgentTypes.ta]: _types.AgentNames.GRAYLOG_TA
|
|
136
|
+
},
|
|
137
|
+
GatewayDisplay: _types.GatewayTypes.GRAYLOG
|
|
138
|
+
};
|
|
139
|
+
const testables = exports.testables = {
|
|
140
|
+
prompts,
|
|
141
|
+
ConfigFiles
|
|
142
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createSecret = exports.createNewDataPlaneSecretResource = exports.createNewDataPlaneResource = exports.createNewAgentResource = exports.createDosaAndCerts = exports.createByResourceType = exports.createBackUpConfigs = void 0;
|
|
6
|
+
exports.updateSubResourceType = exports.createSecret = exports.createNewDataPlaneSecretResource = exports.createNewDataPlaneResource = exports.createNewAgentResource = exports.createDosaAndCerts = exports.createByResourceType = exports.createBackUpConfigs = void 0;
|
|
7
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
8
|
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
@@ -51,22 +51,62 @@ const createDosaAndCerts = async (client, name) => {
|
|
|
51
51
|
return new _types.DosaAccount(account.client_id, publicKey, privateKey);
|
|
52
52
|
};
|
|
53
53
|
exports.createDosaAndCerts = createDosaAndCerts;
|
|
54
|
-
const
|
|
54
|
+
const updateSubResourceType = async (client, defsManager, name, resourceType, resourceShortName, scopeName = '', subResources = {}) => {
|
|
55
|
+
var _defs$0$resource$spec, _defs$0$resource$spec2;
|
|
56
|
+
const defs = defsManager.findDefsByWord(resourceShortName);
|
|
57
|
+
if (!defs) {
|
|
58
|
+
throw Error(`the server doesn't have a resource type "${resourceType}"`);
|
|
59
|
+
}
|
|
60
|
+
const knownSubResourcesNames = (_defs$0$resource$spec = (_defs$0$resource$spec2 = defs[0].resource.spec.subResources) === null || _defs$0$resource$spec2 === void 0 ? void 0 : _defs$0$resource$spec2.names) !== null && _defs$0$resource$spec !== void 0 ? _defs$0$resource$spec : [];
|
|
61
|
+
for (let [key, value] of Object.entries(subResources)) {
|
|
62
|
+
if (knownSubResourcesNames.includes(key)) {
|
|
63
|
+
console.log(`Updating subresource ${key} on ${resourceType}`);
|
|
64
|
+
const resource = {
|
|
65
|
+
name
|
|
66
|
+
};
|
|
67
|
+
Object.assign(resource, {
|
|
68
|
+
[key]: value
|
|
69
|
+
});
|
|
70
|
+
await client.updateSubResource({
|
|
71
|
+
resourceDef: defs[0].resource,
|
|
72
|
+
resource: resource,
|
|
73
|
+
subResourceName: key,
|
|
74
|
+
scopeDef: defs[0].scope ? defs[0].scope : undefined,
|
|
75
|
+
scopeName: defs[0].scope ? scopeName || name : undefined
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.updateSubResourceType = updateSubResourceType;
|
|
81
|
+
const createByResourceType = async (client, defsManager, name, resourceType, resourceShortName, spec = {}, scopeName = '', subResources = {}) => {
|
|
82
|
+
var _defs$0$resource$spec3, _defs$0$resource$spec4;
|
|
55
83
|
console.log(`Creating a new ${resourceType}`);
|
|
56
84
|
// NOTE: only a first found set is used
|
|
57
85
|
const defs = defsManager.findDefsByWord(resourceShortName);
|
|
58
86
|
if (!defs) {
|
|
59
87
|
throw Error(`the server doesn't have a resource type "${resourceType}"`);
|
|
60
88
|
}
|
|
89
|
+
|
|
90
|
+
// @ts-ignore payload
|
|
91
|
+
const resource = {
|
|
92
|
+
name,
|
|
93
|
+
spec
|
|
94
|
+
};
|
|
95
|
+
const knownSubResourcesNames = (_defs$0$resource$spec3 = (_defs$0$resource$spec4 = defs[0].resource.spec.subResources) === null || _defs$0$resource$spec4 === void 0 ? void 0 : _defs$0$resource$spec4.names) !== null && _defs$0$resource$spec3 !== void 0 ? _defs$0$resource$spec3 : [];
|
|
96
|
+
for (let [key, value] of Object.entries(subResources)) {
|
|
97
|
+
if (knownSubResourcesNames.includes(key)) {
|
|
98
|
+
Object.assign(resource, {
|
|
99
|
+
[key]: value
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const withSubRes = subResources !== null;
|
|
61
104
|
const result = await client.createResource({
|
|
62
|
-
|
|
63
|
-
resource: {
|
|
64
|
-
name,
|
|
65
|
-
spec
|
|
66
|
-
},
|
|
105
|
+
resource,
|
|
67
106
|
resourceDef: defs[0].resource,
|
|
68
107
|
scopeDef: defs[0].scope ? defs[0].scope : undefined,
|
|
69
|
-
scopeName: defs[0].scope ? scopeName || name : undefined
|
|
108
|
+
scopeName: defs[0].scope ? scopeName || name : undefined,
|
|
109
|
+
withSubResources: withSubRes
|
|
70
110
|
});
|
|
71
111
|
if (!result.data) {
|
|
72
112
|
var _result$error;
|
|
@@ -152,6 +152,18 @@ Object.keys(_kafkaTemplates).forEach(function (key) {
|
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
|
+
var _graylogTemplates = require("./templates/graylogTemplates");
|
|
156
|
+
Object.keys(_graylogTemplates).forEach(function (key) {
|
|
157
|
+
if (key === "default" || key === "__esModule") return;
|
|
158
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
159
|
+
if (key in exports && exports[key] === _graylogTemplates[key]) return;
|
|
160
|
+
Object.defineProperty(exports, key, {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function () {
|
|
163
|
+
return _graylogTemplates[key];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
155
167
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
156
168
|
const streamPipeline = exports.streamPipeline = _util.default.promisify(_stream.default.pipeline);
|
|
157
169
|
const unzip = async filePath => {
|
|
@@ -180,7 +192,8 @@ const agentsDocsUrl = exports.agentsDocsUrl = {
|
|
|
180
192
|
V7: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/index.html',
|
|
181
193
|
AWS: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_aws_gateway/index.html',
|
|
182
194
|
AZURE: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_azure_gateway/index.html',
|
|
183
|
-
ISTIO: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/mesh_management/index.html'
|
|
195
|
+
ISTIO: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/mesh_management/index.html',
|
|
196
|
+
GRAYLOG: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/mesh_management/index.html'
|
|
184
197
|
};
|
|
185
198
|
|
|
186
199
|
// export * from './updaters';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.transactionLoggingMessages = exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = void 0;
|
|
6
|
+
exports.transactionLoggingMessages = exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = void 0;
|
|
7
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
8
|
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
9
9
|
var _basicPrompts = require("../../../common/basicPrompts");
|
|
@@ -19,6 +19,9 @@ const envMessages = exports.envMessages = {
|
|
|
19
19
|
enterEnvironmentName: 'Enter a new environment name',
|
|
20
20
|
isProduction: 'Is the environment used for production purpose?',
|
|
21
21
|
selectEnvironment: 'Select an environment',
|
|
22
|
+
selectReferencedEnvironment: 'Select a referenced environment',
|
|
23
|
+
selectMoreWithExistingRefEnv: "Selected environment already contains references, do you want to select more",
|
|
24
|
+
selectMoreRefEnv: "Do you want to select more referenced environment",
|
|
22
25
|
getEnvironmentsError: 'Get environments error.',
|
|
23
26
|
environmentAlreadyExists: 'Environment already exists. Please enter a new name.',
|
|
24
27
|
selectTeam: 'Select a team'
|
|
@@ -239,13 +242,60 @@ const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) =>
|
|
|
239
242
|
isNew: true
|
|
240
243
|
};
|
|
241
244
|
} else {
|
|
245
|
+
var _selectedEnv$referenc;
|
|
246
|
+
const selectedEnv = envs.find(env => env.name == answer);
|
|
242
247
|
return {
|
|
243
248
|
name: answer,
|
|
244
|
-
isNew: false
|
|
249
|
+
isNew: false,
|
|
250
|
+
referencedEnvironments: selectedEnv === null || selectedEnv === void 0 ? void 0 : (_selectedEnv$referenc = selectedEnv.references) === null || _selectedEnv$referenc === void 0 ? void 0 : _selectedEnv$referenc.managedEnvironments
|
|
245
251
|
};
|
|
246
252
|
}
|
|
247
253
|
};
|
|
248
254
|
exports.askEnvironmentName = askEnvironmentName;
|
|
255
|
+
const askReferencedEnvironments = async (client, defsManager, envInfo) => {
|
|
256
|
+
var _envInfo$referencedEn;
|
|
257
|
+
if (((_envInfo$referencedEn = envInfo.referencedEnvironments) === null || _envInfo$referencedEn === void 0 ? void 0 : _envInfo$referencedEn.length) > 0) {
|
|
258
|
+
const choice = (await (0, _basicPrompts.askList)({
|
|
259
|
+
msg: envMessages.selectMoreWithExistingRefEnv,
|
|
260
|
+
default: _types.YesNo.No,
|
|
261
|
+
choices: _types.YesNoChoices
|
|
262
|
+
})) === _types.YesNo.Yes;
|
|
263
|
+
if (!choice) {
|
|
264
|
+
return envInfo.referencedEnvironments;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// filter all environments not referencing other environment
|
|
269
|
+
const {
|
|
270
|
+
data: allEnvs
|
|
271
|
+
} = await (0, _getters.getListByResource)({
|
|
272
|
+
client,
|
|
273
|
+
defsManager,
|
|
274
|
+
resourceType: 'Environment',
|
|
275
|
+
resourceShortName: 'env',
|
|
276
|
+
query: "metadata.references.kind!=Environment"
|
|
277
|
+
});
|
|
278
|
+
if (!allEnvs) throw Error(envMessages.getEnvironmentsError);
|
|
279
|
+
let askReferencedEnvironments = true;
|
|
280
|
+
const selectedRefEnv = envInfo.referencedEnvironments ? [...envInfo.referencedEnvironments] : [];
|
|
281
|
+
const envFilter = name => {
|
|
282
|
+
return !(selectedRefEnv !== null && selectedRefEnv !== void 0 && selectedRefEnv.includes(name)) && name != envInfo.name;
|
|
283
|
+
};
|
|
284
|
+
while (askReferencedEnvironments) {
|
|
285
|
+
let selectedEnv = await (0, _basicPrompts.askList)({
|
|
286
|
+
msg: envMessages.selectReferencedEnvironment,
|
|
287
|
+
choices: [...allEnvs.filter(e => envFilter(e.name)).map(e => e.name).sort((n, m) => n.localeCompare(m))]
|
|
288
|
+
});
|
|
289
|
+
selectedRefEnv.push(selectedEnv);
|
|
290
|
+
askReferencedEnvironments = (await (0, _basicPrompts.askList)({
|
|
291
|
+
msg: envMessages.selectMoreRefEnv,
|
|
292
|
+
default: _types.YesNo.No,
|
|
293
|
+
choices: _types.YesNoChoices
|
|
294
|
+
})) === _types.YesNo.Yes;
|
|
295
|
+
}
|
|
296
|
+
return selectedRefEnv;
|
|
297
|
+
};
|
|
298
|
+
exports.askReferencedEnvironments = askReferencedEnvironments;
|
|
249
299
|
const askK8sClusterName = async (client, defsManager) => {
|
|
250
300
|
const {
|
|
251
301
|
data: k8sCluster
|
|
@@ -69,18 +69,21 @@ APIMANAGER_AUTH_PASSWORD={{apiManagerAuthPass}}
|
|
|
69
69
|
APIMANAGER_AUTH_USERNAME={{apiManagerAuthUser}}
|
|
70
70
|
APIMANAGER_HOST={{apiManagerHost}}
|
|
71
71
|
APIMANAGER_PORT={{apiManagerPort}}
|
|
72
|
-
|
|
73
72
|
{{/unless}}
|
|
73
|
+
{{#if isGatewayOnly}}
|
|
74
|
+
APIGATEWAY_ONLY={{isGatewayOnly}}
|
|
75
|
+
{{/if}}
|
|
76
|
+
{{#if traceabilityConfig.usageReportingOffline}}
|
|
77
|
+
APIGATEWAY_GETHEADERS=false
|
|
78
|
+
{{else}}
|
|
74
79
|
{{#unless isOpenTraffic}}
|
|
75
80
|
# API Gateway configs
|
|
76
81
|
APIGATEWAY_AUTH_PASSWORD={{apiGatewayAuthPass}}
|
|
77
82
|
APIGATEWAY_AUTH_USERNAME={{apiGatewayAuthUser}}
|
|
78
83
|
APIGATEWAY_HOST={{apiGatewayHost}}
|
|
79
84
|
APIGATEWAY_PORT={{apiGatewayPort}}
|
|
80
|
-
{{#if isGatewayOnly}}
|
|
81
|
-
APIGATEWAY_ONLY={{isGatewayOnly}}
|
|
82
|
-
{{/if}}
|
|
83
85
|
{{/unless}}
|
|
86
|
+
{{/if}}
|
|
84
87
|
{{#if eventLogPathTemplate}}
|
|
85
88
|
{{#if isOpenTraffic}}
|
|
86
89
|
# API Gateway open traffic logs
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.graylogHelmOverrideTemplate = exports.GraylogAgentValues = void 0;
|
|
7
|
+
var _types = require("../../../../common/types");
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
/**
|
|
12
|
+
* @description Parameters to provide to the Graylog handlebars templates.
|
|
13
|
+
*/
|
|
14
|
+
class GraylogAgentValues {
|
|
15
|
+
constructor() {
|
|
16
|
+
_defineProperty(this, "namespace", void 0);
|
|
17
|
+
_defineProperty(this, "url", void 0);
|
|
18
|
+
_defineProperty(this, "graylogSecret", void 0);
|
|
19
|
+
_defineProperty(this, "agentKeysSecret", void 0);
|
|
20
|
+
_defineProperty(this, "userName", void 0);
|
|
21
|
+
_defineProperty(this, "password", void 0);
|
|
22
|
+
_defineProperty(this, "basePathSegmentLen", void 0);
|
|
23
|
+
_defineProperty(this, "centralConfig", void 0);
|
|
24
|
+
_defineProperty(this, "traceabilityConfig", void 0);
|
|
25
|
+
this.namespace = {
|
|
26
|
+
name: '',
|
|
27
|
+
isNew: false
|
|
28
|
+
};
|
|
29
|
+
this.url = '';
|
|
30
|
+
this.graylogSecret = '';
|
|
31
|
+
this.agentKeysSecret = '';
|
|
32
|
+
this.userName = '';
|
|
33
|
+
this.password = '';
|
|
34
|
+
this.basePathSegmentLen = 2;
|
|
35
|
+
this.centralConfig = new _types.CentralAgentConfig();
|
|
36
|
+
this.traceabilityConfig = new _types.TraceabilityConfig();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description Generates the helm override file for the Amplify Graylog Agent.
|
|
42
|
+
*/
|
|
43
|
+
exports.GraylogAgentValues = GraylogAgentValues;
|
|
44
|
+
const graylogHelmOverrideTemplate = () => {
|
|
45
|
+
return `---
|
|
46
|
+
graylog:
|
|
47
|
+
url: {{url}}
|
|
48
|
+
basePathSegmentLen: {{basePathSegmentLen}}
|
|
49
|
+
|
|
50
|
+
secrets:
|
|
51
|
+
graylog:
|
|
52
|
+
name: {{graylogSecret}}
|
|
53
|
+
agent:
|
|
54
|
+
name: {{agentKeysSecret}}
|
|
55
|
+
|
|
56
|
+
env:
|
|
57
|
+
CENTRAL_SINGLEURL: {{centralConfig.singleEntryPointUrl}}
|
|
58
|
+
CENTRAL_URL: {{centralConfig.url}}
|
|
59
|
+
CENTRAL_AUTH_URL: {{centralConfig.authUrl}}
|
|
60
|
+
CENTRAL_ORGANIZATIONID: "{{centralConfig.orgId}}"
|
|
61
|
+
CENTRAL_DEPLOYMENT: {{centralConfig.deployment}}
|
|
62
|
+
CENTRAL_TEAM: {{centralConfig.ampcTeamName}}
|
|
63
|
+
CENTRAL_ENVIRONMENT: {{centralConfig.environment}}
|
|
64
|
+
CENTRAL_AGENTNAME: {{centralConfig.taAgentName}}
|
|
65
|
+
CENTRAL_AUTH_CLIENTID: {{centralConfig.dosaAccount.clientId}}
|
|
66
|
+
TRACEABILITY_HOST: {{traceabilityConfig.host}}
|
|
67
|
+
TRACEABILITY_PROTOCOL: {{traceabilityConfig.protocol}}
|
|
68
|
+
`;
|
|
69
|
+
};
|
|
70
|
+
exports.graylogHelmOverrideTemplate = graylogHelmOverrideTemplate;
|
|
@@ -317,7 +317,7 @@ const createHybridOverride = overrides => {
|
|
|
317
317
|
(0, _utils.writeTemplates)(overrideFileName, overrides, helpers.istioAgentsTemplate);
|
|
318
318
|
console.log(`Istio agent override file has been placed at ${process.cwd()}/${overrideFileName}`);
|
|
319
319
|
const installCmd = `helm upgrade --install --namespace ${overrides.istioAgentValues.namespace.name} ampc-hybrid axway/ampc-hybrid -f ${overrideFileName}`;
|
|
320
|
-
console.log('To complete the Istio agent installation run the following commands:', _chalk.default.cyan('\n helm repo add axway https://
|
|
320
|
+
console.log('To complete the Istio agent installation run the following commands:', _chalk.default.cyan('\n helm repo add axway https://helm.repository.axway.com --username=<client_id> --password=<client_secret>'), _chalk.default.cyan(`\n helm repo update\n ${installCmd}`), _chalk.default.cyan(`\n`), _chalk.default.white(`\n* client_id - service account id for your Amplify Platform organization`), _chalk.default.white(`\n* client_secret - service account secret for your Amplify Platform organization`));
|
|
321
321
|
};
|
|
322
322
|
exports.createHybridOverride = createHybridOverride;
|
|
323
323
|
const installPreprocess = async installConfig => {
|
|
@@ -47,7 +47,7 @@ const getTraceabilityConfig = async installConfig => {
|
|
|
47
47
|
// Do not ask Traceability questions in offline mode
|
|
48
48
|
if (!traceabilityConfig.usageReportingOffline) {
|
|
49
49
|
console.log('\nCONNECTION TO TRACEABILITY MODULE:');
|
|
50
|
-
if (installConfig.gatewayType !== _types.GatewayTypes.KAFKA) {
|
|
50
|
+
if (installConfig.gatewayType !== _types.GatewayTypes.KAFKA && installConfig.gatewayType !== _types.GatewayTypes.GRAYLOG) {
|
|
51
51
|
const {
|
|
52
52
|
enabled,
|
|
53
53
|
samplingPercentage,
|
|
@@ -80,6 +80,16 @@ const getCentralConfig = async (apiServerClient, platformClient, defsManager, ap
|
|
|
80
80
|
centralConfig.orgId = await helpers.getCurrentUserOrgId();
|
|
81
81
|
centralConfig.ampcEnvInfo = await helpers.askEnvironmentName(apiServerClient, defsManager, centralConfig.axwayManaged);
|
|
82
82
|
centralConfig.production = centralConfig.ampcEnvInfo.isNew ? await askIsProductionEnvironment() : false;
|
|
83
|
+
if (installConfig.gatewayType === _types.GatewayTypes.GRAYLOG) {
|
|
84
|
+
const updatedRefEnvs = await helpers.askReferencedEnvironments(apiServerClient, defsManager, centralConfig.ampcEnvInfo);
|
|
85
|
+
const compareRefs = (a, b) => {
|
|
86
|
+
return (a === null || a === void 0 ? void 0 : a.length) === (b === null || b === void 0 ? void 0 : b.length) && (a === null || a === void 0 ? void 0 : a.every(element => b === null || b === void 0 ? void 0 : b.includes(element)));
|
|
87
|
+
};
|
|
88
|
+
if (!compareRefs(updatedRefEnvs, centralConfig.ampcEnvInfo.referencedEnvironments)) {
|
|
89
|
+
centralConfig.ampcEnvInfo.referencedEnvironments = updatedRefEnvs;
|
|
90
|
+
centralConfig.ampcEnvInfo.isUpdated = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
83
93
|
if (!installConfig.switches.isOrgRep) {
|
|
84
94
|
centralConfig.ampcTeamName = await askTeamName(platformClient);
|
|
85
95
|
}
|
|
@@ -118,12 +128,23 @@ const finalizeCentralInstall = async (apiServerClient, platformClient, defsManag
|
|
|
118
128
|
installConfig.centralConfig.dosaAccount.clientId = installConfig.centralConfig.ampcDosaInfo.clientId;
|
|
119
129
|
}
|
|
120
130
|
installConfig.centralConfig.dosaAccount.updateKeyTemplateValues(installConfig.deploymentType);
|
|
131
|
+
let refEnvSubResource;
|
|
132
|
+
if (installConfig.centralConfig.ampcEnvInfo.referencedEnvironments) {
|
|
133
|
+
refEnvSubResource = {
|
|
134
|
+
references: {
|
|
135
|
+
managedEnvironments: installConfig.centralConfig.ampcEnvInfo.referencedEnvironments
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
121
139
|
|
|
122
140
|
// environment name
|
|
123
141
|
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
124
142
|
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
125
143
|
production: installConfig.centralConfig.production
|
|
126
|
-
}) : installConfig.centralConfig.ampcEnvInfo.name;
|
|
144
|
+
}, '', refEnvSubResource) : installConfig.centralConfig.ampcEnvInfo.name;
|
|
145
|
+
if (installConfig.centralConfig.ampcEnvInfo.isUpdated) {
|
|
146
|
+
await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refEnvSubResource);
|
|
147
|
+
}
|
|
127
148
|
|
|
128
149
|
// Create DiscoveryAgent Resource unless gateway type is Istio. This can be removed when this is available for Istio
|
|
129
150
|
if (installConfig.centralConfig.daAgentName != '') {
|
|
@@ -327,6 +327,58 @@ class ApiServerClient {
|
|
|
327
327
|
return result;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Update sub resource on the resource.
|
|
332
|
+
* @param resources resource to be updated
|
|
333
|
+
* @param subResourceName sub resource name to be updated
|
|
334
|
+
*/
|
|
335
|
+
async updateSubResource({
|
|
336
|
+
resourceDef,
|
|
337
|
+
resource,
|
|
338
|
+
subResourceName,
|
|
339
|
+
scopeDef,
|
|
340
|
+
scopeName,
|
|
341
|
+
version = ApiServerVersions.v1alpha1
|
|
342
|
+
}) {
|
|
343
|
+
log(`updateSubResource, spec.kind = ${resourceDef.spec.kind}, name = ${resource.name}`);
|
|
344
|
+
const result = {
|
|
345
|
+
data: null,
|
|
346
|
+
error: null,
|
|
347
|
+
pending: null
|
|
348
|
+
};
|
|
349
|
+
try {
|
|
350
|
+
var _resourceDef$spec$sub3, _resourceDef$spec$sub4;
|
|
351
|
+
const service = await (0, _dataService.dataService)({
|
|
352
|
+
baseUrl: this.baseUrl,
|
|
353
|
+
region: this.region,
|
|
354
|
+
account: this.account,
|
|
355
|
+
team: this.team
|
|
356
|
+
});
|
|
357
|
+
const knownSubResourcesNames = (_resourceDef$spec$sub3 = (_resourceDef$spec$sub4 = resourceDef.spec.subResources) === null || _resourceDef$spec$sub4 === void 0 ? void 0 : _resourceDef$spec$sub4.names) !== null && _resourceDef$spec$sub3 !== void 0 ? _resourceDef$spec$sub3 : [];
|
|
358
|
+
const foundSubResources = (0, _pickBy.default)(resource, (_, key) => subResourceName == key && knownSubResourcesNames.includes(key));
|
|
359
|
+
const resourceName = resource.name;
|
|
360
|
+
const baseUrl = this.buildResourceBaseUrl({
|
|
361
|
+
resourceDef,
|
|
362
|
+
resourceName,
|
|
363
|
+
scopeDef,
|
|
364
|
+
scopeName,
|
|
365
|
+
version
|
|
366
|
+
});
|
|
367
|
+
service.put(`${baseUrl}/${subResourceName}?fields=${subResourceName}`, {
|
|
368
|
+
[subResourceName]: foundSubResources[subResourceName]
|
|
369
|
+
});
|
|
370
|
+
} catch (e) {
|
|
371
|
+
log('updateSubResource, error', e);
|
|
372
|
+
// expecting only a valid ApiServer error response here
|
|
373
|
+
// re-throw if something different, so it should be handled by command's catch block.
|
|
374
|
+
if (e.errors && Array.isArray(e.errors)) {
|
|
375
|
+
result.error = e.errors;
|
|
376
|
+
} else throw e;
|
|
377
|
+
}
|
|
378
|
+
if (!!result.data) result.data = (0, _utils.sanitizeMetadata)(result.data);
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
|
|
330
382
|
/**
|
|
331
383
|
* Delete a resources by name.
|
|
332
384
|
* @param opts = {
|
package/dist/common/types.js
CHANGED
|
@@ -224,6 +224,7 @@ let AgentNames = exports.AgentNames = /*#__PURE__*/function (AgentNames) {
|
|
|
224
224
|
AgentNames["KAFKA_DA"] = "kafka-discovery-agent";
|
|
225
225
|
AgentNames["KAFKA_TA"] = "kafka-traceability-agent";
|
|
226
226
|
AgentNames["SWAGGERHUB_DA"] = "swaggerhub-discovery-agent";
|
|
227
|
+
AgentNames["GRAYLOG_TA"] = "graylog-agent";
|
|
227
228
|
return AgentNames;
|
|
228
229
|
}({});
|
|
229
230
|
let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
|
|
@@ -234,6 +235,7 @@ let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
|
|
|
234
235
|
GatewayTypes["ISTIO"] = "Istio";
|
|
235
236
|
GatewayTypes["EDGE_GATEWAY_ONLY"] = "Amplify API Gateway only";
|
|
236
237
|
GatewayTypes["KAFKA"] = "Kafka";
|
|
238
|
+
GatewayTypes["GRAYLOG"] = "Graylog";
|
|
237
239
|
return GatewayTypes;
|
|
238
240
|
}({});
|
|
239
241
|
let SaaSGatewayTypes = exports.SaaSGatewayTypes = /*#__PURE__*/function (SaaSGatewayTypes) {
|
|
@@ -251,6 +253,7 @@ let DataPlaneNames = exports.DataPlaneNames = /*#__PURE__*/function (DataPlaneNa
|
|
|
251
253
|
DataPlaneNames["AZURE"] = "Azure";
|
|
252
254
|
DataPlaneNames["EDGE"] = "Edge";
|
|
253
255
|
DataPlaneNames["KAFKA"] = "Kafka";
|
|
256
|
+
DataPlaneNames["GRAYLOG"] = "Graylog";
|
|
254
257
|
DataPlaneNames["KONG"] = "Kong";
|
|
255
258
|
DataPlaneNames["SWAGGERHUB"] = "SwaggerHub";
|
|
256
259
|
DataPlaneNames["MULESOFT"] = "Mulesoft";
|
|
@@ -268,7 +271,8 @@ const GatewayTypeToDataPlane = exports.GatewayTypeToDataPlane = {
|
|
|
268
271
|
[GatewayTypes.ISTIO]: 'Istio',
|
|
269
272
|
[SaaSGatewayTypes.APIGEEX_GATEWAY]: DataPlaneNames.APIGEE,
|
|
270
273
|
[GatewayTypes.KAFKA]: DataPlaneNames.KAFKA,
|
|
271
|
-
[SaaSGatewayTypes.SWAGGERHUB]: DataPlaneNames.SWAGGERHUB
|
|
274
|
+
[SaaSGatewayTypes.SWAGGERHUB]: DataPlaneNames.SWAGGERHUB,
|
|
275
|
+
[GatewayTypes.GRAYLOG]: DataPlaneNames.GRAYLOG
|
|
272
276
|
};
|
|
273
277
|
let AgentResourceKind = exports.AgentResourceKind = /*#__PURE__*/function (AgentResourceKind) {
|
|
274
278
|
AgentResourceKind["da"] = "DiscoveryAgent";
|
|
@@ -299,8 +303,12 @@ class EnvironmentConfigInfo {
|
|
|
299
303
|
constructor() {
|
|
300
304
|
_defineProperty(this, "name", void 0);
|
|
301
305
|
_defineProperty(this, "isNew", void 0);
|
|
306
|
+
_defineProperty(this, "isUpdated", void 0);
|
|
307
|
+
_defineProperty(this, "referencedEnvironments", void 0);
|
|
302
308
|
this.name = '';
|
|
303
309
|
this.isNew = false;
|
|
310
|
+
this.isUpdated = false;
|
|
311
|
+
this.referencedEnvironments = [];
|
|
304
312
|
}
|
|
305
313
|
}
|
|
306
314
|
exports.EnvironmentConfigInfo = EnvironmentConfigInfo;
|