-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
index.ts
78 lines (71 loc) · 2.59 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { GetDeprecationsContext, DeprecationsDetails } from 'src/core/server';
import { i18n } from '@kbn/i18n';
import { isEmpty } from 'lodash';
import { CloudSetup } from '../../../cloud/server';
import {
getCloudAgentPolicy,
getApmPackagePolicy,
} from '../lib/fleet/get_cloud_apm_package_policy';
import { APMRouteHandlerResources } from '../';
export function getDeprecations({
cloudSetup,
fleet,
branch,
}: {
cloudSetup?: CloudSetup;
fleet?: APMRouteHandlerResources['plugins']['fleet'];
branch: string;
}) {
return async ({
savedObjectsClient,
}: GetDeprecationsContext): Promise<DeprecationsDetails[]> => {
const deprecations: DeprecationsDetails[] = [];
if (!fleet) {
return deprecations;
}
const fleetPluginStart = await fleet.start();
const cloudAgentPolicy = await getCloudAgentPolicy({
fleetPluginStart,
savedObjectsClient,
});
const isCloudEnabled = !!cloudSetup?.isCloudEnabled;
const hasAPMPackagePolicy = !isEmpty(getApmPackagePolicy(cloudAgentPolicy));
if (isCloudEnabled && !hasAPMPackagePolicy) {
deprecations.push({
title: i18n.translate('xpack.apm.deprecations.legacyModeTitle', {
defaultMessage: 'APM Server running in legacy mode',
}),
message: i18n.translate('xpack.apm.deprecations.message', {
defaultMessage:
'Running the APM Server binary directly is considered a legacy option and will be deprecated and removed in the future.',
}),
documentationUrl: `https://www.elastic.co/guide/en/apm/server/${branch}/apm-integration.html`,
level: 'warning',
correctiveActions: {
manualSteps: [
i18n.translate('xpack.apm.deprecations.steps.apm', {
defaultMessage: 'Navigate to Observability/APM',
}),
i18n.translate('xpack.apm.deprecations.steps.settings', {
defaultMessage: 'Click on "Settings"',
}),
i18n.translate('xpack.apm.deprecations.steps.schema', {
defaultMessage: 'Select "Schema" tab',
}),
i18n.translate('xpack.apm.deprecations.steps.switch', {
defaultMessage:
'Click "Switch to Elastic Agent". You will be guided through the process',
}),
],
},
});
}
return deprecations;
};
}