-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Data Usage] Enabled plugin for Serverless and added feature fl…
…ag to manage availability (#201465) (#201498) # Backport This will backport the following commits from `main` to `8.x`: - [[Data Usage] Enabled plugin for Serverless and added feature flag to manage availability (#201465)](#201465) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Yuliia Naumenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-23T12:06:23Z","message":"[Data Usage] Enabled plugin for Serverless and added feature flag to manage availability (#201465)\n\nThis PR enables data_usage plugin for Serverless environment for all 3\r\nsolutions.\r\nTo manage feature availability added feature flag, which is turning Data\r\nUsage off by default.","sha":"5342f327ee62219c5cf12d50e424da9b91330d5e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:all-open","ci:build-serverless-image","v8.18.0"],"title":"[Data Usage] Enabled plugin for Serverless and added feature flag to manage availability","number":201465,"url":"https://github.com/elastic/kibana/pull/201465","mergeCommit":{"message":"[Data Usage] Enabled plugin for Serverless and added feature flag to manage availability (#201465)\n\nThis PR enables data_usage plugin for Serverless environment for all 3\r\nsolutions.\r\nTo manage feature availability added feature flag, which is turning Data\r\nUsage off by default.","sha":"5342f327ee62219c5cf12d50e424da9b91330d5e"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201465","number":201465,"mergeCommit":{"message":"[Data Usage] Enabled plugin for Serverless and added feature flag to manage availability (#201465)\n\nThis PR enables data_usage plugin for Serverless environment for all 3\r\nsolutions.\r\nTo manage feature availability added feature flag, which is turning Data\r\nUsage off by default.","sha":"5342f327ee62219c5cf12d50e424da9b91330d5e"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Yuliia Naumenko <[email protected]>
- Loading branch information
1 parent
eae4dad
commit ed434a7
Showing
13 changed files
with
151 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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 ServerlessExperimentalFeatures = Record< | ||
keyof typeof allowedExperimentalValues, | ||
boolean | ||
>; | ||
|
||
/** | ||
* A list of allowed values that can be used in `xpack.dataUsage.enableExperimental`. | ||
* This object is then used to validate and parse the value entered. | ||
*/ | ||
export const allowedExperimentalValues = Object.freeze({ | ||
/** | ||
* <Add a description of the feature here> | ||
* | ||
* [This is a fake feature key to showcase how to add a new serverless-specific experimental flag. | ||
* It also prevents `allowedExperimentalValues` from being empty. It should be removed once a real feature is added.] | ||
*/ | ||
dataUsageDisabled: false, | ||
}); | ||
|
||
type ServerlessExperimentalConfigKeys = Array<keyof ServerlessExperimentalFeatures>; | ||
type Mutable<T> = { -readonly [P in keyof T]: T[P] }; | ||
|
||
const allowedKeys = Object.keys( | ||
allowedExperimentalValues | ||
) as Readonly<ServerlessExperimentalConfigKeys>; | ||
|
||
export type ExperimentalFeatures = ServerlessExperimentalFeatures; | ||
/** | ||
* Parses the string value used in `xpack.dataUsage.enableExperimental` kibana configuration, | ||
* which should be a string of values delimited by a comma (`,`) | ||
* The generic experimental features are merged with the serverless values to ensure they are available | ||
* | ||
* @param configValue | ||
* @throws DataUsagenvalidExperimentalValue | ||
*/ | ||
export const parseExperimentalConfigValue = ( | ||
configValue: string[] | ||
): { features: ExperimentalFeatures; invalid: string[] } => { | ||
const enabledFeatures: Mutable<Partial<ExperimentalFeatures>> = {}; | ||
const invalidKeys: string[] = []; | ||
|
||
for (const value of configValue) { | ||
if (!allowedKeys.includes(value as keyof ServerlessExperimentalFeatures)) { | ||
invalidKeys.push(value); | ||
} else { | ||
enabledFeatures[value as keyof ServerlessExperimentalFeatures] = true; | ||
} | ||
} | ||
|
||
return { | ||
features: { | ||
...allowedExperimentalValues, | ||
...enabledFeatures, | ||
}, | ||
invalid: invalidKeys, | ||
}; | ||
}; | ||
|
||
export const getExperimentalAllowedValues = (): string[] => [...allowedKeys]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters