-
Notifications
You must be signed in to change notification settings - Fork 8.2k
/
index.ts
136 lines (125 loc) · 5.11 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* 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 { schema } from '@kbn/config-schema';
import type { TypeOf } from '@kbn/config-schema';
import type { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server';
import {
PreconfiguredPackagesSchema,
PreconfiguredAgentPoliciesSchema,
PreconfiguredOutputsSchema,
} from './types';
import { FleetPlugin } from './plugin';
export { default as apm } from 'elastic-apm-node';
export {
AgentService,
ESIndexPatternService,
getRegistryUrl,
PackageService,
AgentPolicyServiceInterface,
ArtifactsClientInterface,
Artifact,
ListArtifactsProps,
} from './services';
export { FleetSetupContract, FleetSetupDeps, FleetStartContract } from './plugin';
export type {
ExternalCallback,
PutPackagePolicyUpdateCallback,
PostPackagePolicyDeleteCallback,
PostPackagePolicyCreateCallback,
} from './types';
export { AgentNotFoundError } from './errors';
export const config: PluginConfigDescriptor = {
exposeToBrowser: {
epm: true,
agents: true,
},
deprecations: ({ deprecate, renameFromRoot, unused, unusedFromRoot }) => [
deprecate('enabled', '8.0.0'),
// Fleet plugin was named ingestManager before
renameFromRoot('xpack.ingestManager.enabled', 'xpack.fleet.enabled'),
renameFromRoot('xpack.ingestManager.registryUrl', 'xpack.fleet.registryUrl'),
renameFromRoot('xpack.ingestManager.registryProxyUrl', 'xpack.fleet.registryProxyUrl'),
renameFromRoot('xpack.ingestManager.fleet', 'xpack.ingestManager.agents'),
renameFromRoot('xpack.ingestManager.agents.enabled', 'xpack.fleet.agents.enabled'),
renameFromRoot('xpack.ingestManager.agents.elasticsearch', 'xpack.fleet.agents.elasticsearch'),
renameFromRoot(
'xpack.ingestManager.agents.tlsCheckDisabled',
'xpack.fleet.agents.tlsCheckDisabled'
),
renameFromRoot(
'xpack.ingestManager.agents.pollingRequestTimeout',
'xpack.fleet.agents.pollingRequestTimeout'
),
renameFromRoot(
'xpack.ingestManager.agents.maxConcurrentConnections',
'xpack.fleet.agents.maxConcurrentConnections'
),
renameFromRoot('xpack.ingestManager.agents.kibana', 'xpack.fleet.agents.kibana'),
renameFromRoot(
'xpack.ingestManager.agents.agentPolicyRolloutRateLimitIntervalMs',
'xpack.fleet.agents.agentPolicyRolloutRateLimitIntervalMs'
),
renameFromRoot(
'xpack.ingestManager.agents.agentPolicyRolloutRateLimitRequestPerInterval',
'xpack.fleet.agents.agentPolicyRolloutRateLimitRequestPerInterval'
),
unusedFromRoot('xpack.ingestManager'),
// Unused settings before Fleet server exists
unused('agents.kibana'),
unused('agents.maxConcurrentConnections'),
unused('agents.agentPolicyRolloutRateLimitIntervalMs'),
unused('agents.agentPolicyRolloutRateLimitRequestPerInterval'),
unused('agents.pollingRequestTimeout'),
unused('agents.tlsCheckDisabled'),
unused('agents.fleetServerEnabled'),
// Renaming elasticsearch.host => elasticsearch.hosts
(fullConfig, fromPath, addDeprecation) => {
const oldValue = fullConfig?.xpack?.fleet?.agents?.elasticsearch?.host;
if (oldValue) {
delete fullConfig.xpack.fleet.agents.elasticsearch.host;
fullConfig.xpack.fleet.agents.elasticsearch.hosts = [oldValue];
addDeprecation({
configPath: 'xpack.fleet.agents.elasticsearch.host',
message: `Config key [xpack.fleet.agents.elasticsearch.host] is deprecated and replaced by [xpack.fleet.agents.elasticsearch.hosts]`,
correctiveActions: {
manualSteps: [
`Use [xpack.fleet.agents.elasticsearch.hosts] with an array of host instead.`,
],
},
});
}
return fullConfig;
},
],
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
registryUrl: schema.maybe(schema.uri({ scheme: ['http', 'https'] })),
registryProxyUrl: schema.maybe(schema.uri({ scheme: ['http', 'https'] })),
agents: schema.object({
enabled: schema.boolean({ defaultValue: true }),
elasticsearch: schema.object({
hosts: schema.maybe(schema.arrayOf(schema.uri({ scheme: ['http', 'https'] }))),
ca_sha256: schema.maybe(schema.string()),
}),
fleet_server: schema.maybe(
schema.object({
hosts: schema.maybe(schema.arrayOf(schema.uri({ scheme: ['http', 'https'] }))),
})
),
}),
packages: PreconfiguredPackagesSchema,
agentPolicies: PreconfiguredAgentPoliciesSchema,
outputs: PreconfiguredOutputsSchema,
agentIdVerificationEnabled: schema.boolean({ defaultValue: true }),
}),
};
export type FleetConfigType = TypeOf<typeof config.schema>;
export { PackagePolicyServiceInterface } from './services/package_policy';
export { relativeDownloadUrlFromArtifact } from './services/artifacts/mappings';
export const plugin = (initializerContext: PluginInitializerContext) => {
return new FleetPlugin(initializerContext);
};