/
experimental_features.ts
60 lines (51 loc) · 1.88 KB
/
experimental_features.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
/*
* 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.
*/
export type ExperimentalFeatures = typeof allowedExperimentalValues;
/**
* A list of allowed values that can be used in `xpack.fleet.enableExperimental`.
* This object is then used to validate and parse the value entered.
*/
export const allowedExperimentalValues = Object.freeze<Record<string, boolean>>({
createPackagePolicyMultiPageLayout: true,
packageVerification: true,
showDevtoolsRequest: true,
diagnosticFileUploadEnabled: true,
displayAgentMetrics: true,
showIntegrationsSubcategories: true,
agentFqdnMode: true,
showExperimentalShipperOptions: false,
agentTamperProtectionEnabled: true,
secretsStorage: true,
kafkaOutput: true,
outputSecretsStorage: false,
remoteESOutput: false,
});
type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;
type Mutable<T> = { -readonly [P in keyof T]: T[P] };
const allowedKeys = Object.keys(allowedExperimentalValues) as Readonly<ExperimentalConfigKeys>;
/**
* Parses the string value used in `xpack.fleet.enableExperimental` kibana configuration,
* which should be a string of values delimited by a comma (`,`)
*
* @param configValue
*/
export const parseExperimentalConfigValue = (configValue: string[]): ExperimentalFeatures => {
const enabledFeatures: Mutable<ExperimentalFeatures> = {};
for (const value of configValue) {
if (isValidExperimentalValue(value)) {
enabledFeatures[value] = true;
}
}
return {
...allowedExperimentalValues,
...enabledFeatures,
};
};
export const isValidExperimentalValue = (value: string) => {
return allowedKeys.includes(value);
};
export const getExperimentalAllowedValues = (): string[] => [...allowedKeys];