-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements config deprecation in New Platform #52251
Merged
pgayvallet
merged 33 commits into
elastic:master
from
pgayvallet:kbn-40255-NP-config-deprecation
Dec 13, 2019
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
1c5dc41
implements 'rename' and 'unset' deprecations
pgayvallet 52e34f9
introduce usage of ConfigDeprecationProvider
pgayvallet 033193b
adapt RawConfigService to only returns unmodified raw config
pgayvallet 2fe6f97
apply deprecations when accessing config
pgayvallet 3dbd4b1
register legacy plugin deprecation in new platform
pgayvallet a0f0dea
implements ConfigService#validate
pgayvallet d2dba27
add exemple config deprecation usage in testbed
pgayvallet 181cd74
documentation
pgayvallet c078836
export public config deprecation types
pgayvallet 31a9c38
fix new test due to rebase
pgayvallet c0725d3
name ConfigDeprecationFactory
pgayvallet 995e02e
update generated doc
pgayvallet 9feead7
add tests for unset and move it to src/core/utils
pgayvallet 9d32148
add tests for renameFromRoot and unusedFromRoot
pgayvallet 14b8727
Merge remote-tracking branch 'upstream/master' into kbn-40255-NP-conf…
pgayvallet 55604f7
cast paths as any as get expects a fixed-length string array
pgayvallet 5ec122d
use specific logger for deprecations
pgayvallet a8e14c1
add additional test on renameFromRoot
pgayvallet 8c71f61
update migration guide
pgayvallet 6f6f920
migrate core deprecations to NP
pgayvallet 02bbaa8
add integration test
pgayvallet eb45292
Merge remote-tracking branch 'upstream/master' into kbn-40255-NP-conf…
pgayvallet 7965da3
use same log context as legacy
pgayvallet ba45ea8
remove old deprecation warnings integration tests, now covered in NP
pgayvallet efe2ec8
migrates csp deprecation to NP
pgayvallet 46b7532
removes deprecationWarningMixin from legacy
pgayvallet b9e0c6c
remove legacy core deprecations
pgayvallet 03549fa
Merge remote-tracking branch 'upstream/master' into kbn-40255-NP-conf…
pgayvallet b44d9e1
Merge remote-tracking branch 'upstream/master' into kbn-40255-NP-conf…
pgayvallet 46a4f73
remove unused import
pgayvallet d432d8a
rename setupConfigSchemas to setupCoreConfig
pgayvallet d402ac7
update generated doc
pgayvallet bb9ee0e
Merge remote-tracking branch 'upstream/master' into kbn-40255-NP-conf…
pgayvallet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 18 additions & 0 deletions
18
docs/development/core/server/kibana-plugin-server.configdeprecation.md
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,18 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) | ||
|
||
## ConfigDeprecation type | ||
|
||
Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type ConfigDeprecation = (config: Record<string, any>, fromPath: string, logger: ConfigDeprecationLogger) => Record<string, any>; | ||
``` | ||
|
||
## Remarks | ||
|
||
This should only be manually implemented if [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) does not provide the proper helpers for a specific deprecation need. | ||
|
36 changes: 36 additions & 0 deletions
36
docs/development/core/server/kibana-plugin-server.configdeprecationfactory.md
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,36 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) | ||
|
||
## ConfigDeprecationFactory interface | ||
|
||
Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md)<!-- -->. | ||
|
||
See methods documentation for more detailed examples. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface ConfigDeprecationFactory | ||
``` | ||
|
||
## Methods | ||
|
||
| Method | Description | | ||
| --- | --- | | ||
| [rename(oldKey, newKey)](./kibana-plugin-server.configdeprecationfactory.rename.md) | Rename a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the oldKey was found and deprecation applied. | | ||
| [renameFromRoot(oldKey, newKey)](./kibana-plugin-server.configdeprecationfactory.renamefromroot.md) | Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied.<!-- -->This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. | | ||
| [unused(unusedKey)](./kibana-plugin-server.configdeprecationfactory.unused.md) | Remove a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the unused key was found and deprecation applied. | | ||
| [unusedFromRoot(unusedKey)](./kibana-plugin-server.configdeprecationfactory.unusedfromroot.md) | Remove a configuration property from the root configuration. Will log a deprecation warning if the unused key was found and deprecation applied.<!-- -->This should be only used when removing properties from outside of a plugin's configuration. To remove properties from inside a plugin's configuration, use 'unused' instead. | | ||
|
||
## Example | ||
|
||
|
||
```typescript | ||
const provider: ConfigDeprecationProvider = ({ rename, unused }) => [ | ||
rename('oldKey', 'newKey'), | ||
unused('deprecatedKey'), | ||
] | ||
|
||
``` | ||
|
36 changes: 36 additions & 0 deletions
36
...development/core/server/kibana-plugin-server.configdeprecationfactory.rename.md
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,36 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) > [rename](./kibana-plugin-server.configdeprecationfactory.rename.md) | ||
|
||
## ConfigDeprecationFactory.rename() method | ||
|
||
Rename a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the oldKey was found and deprecation applied. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
rename(oldKey: string, newKey: string): ConfigDeprecation; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| oldKey | <code>string</code> | | | ||
| newKey | <code>string</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`ConfigDeprecation` | ||
|
||
## Example | ||
|
||
Rename 'myplugin.oldKey' to 'myplugin.newKey' | ||
|
||
```typescript | ||
const provider: ConfigDeprecationProvider = ({ rename }) => [ | ||
rename('oldKey', 'newKey'), | ||
] | ||
|
||
``` | ||
|
38 changes: 38 additions & 0 deletions
38
...ent/core/server/kibana-plugin-server.configdeprecationfactory.renamefromroot.md
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,38 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) > [renameFromRoot](./kibana-plugin-server.configdeprecationfactory.renamefromroot.md) | ||
|
||
## ConfigDeprecationFactory.renameFromRoot() method | ||
|
||
Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied. | ||
|
||
This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| oldKey | <code>string</code> | | | ||
| newKey | <code>string</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`ConfigDeprecation` | ||
|
||
## Example | ||
|
||
Rename 'oldplugin.key' to 'newplugin.key' | ||
|
||
```typescript | ||
const provider: ConfigDeprecationProvider = ({ renameFromRoot }) => [ | ||
renameFromRoot('oldplugin.key', 'newplugin.key'), | ||
] | ||
|
||
``` | ||
|
35 changes: 35 additions & 0 deletions
35
...development/core/server/kibana-plugin-server.configdeprecationfactory.unused.md
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,35 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) > [unused](./kibana-plugin-server.configdeprecationfactory.unused.md) | ||
|
||
## ConfigDeprecationFactory.unused() method | ||
|
||
Remove a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the unused key was found and deprecation applied. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
unused(unusedKey: string): ConfigDeprecation; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| unusedKey | <code>string</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`ConfigDeprecation` | ||
|
||
## Example | ||
|
||
Flags 'myplugin.deprecatedKey' as unused | ||
|
||
```typescript | ||
const provider: ConfigDeprecationProvider = ({ unused }) => [ | ||
unused('deprecatedKey'), | ||
] | ||
|
||
``` | ||
|
37 changes: 37 additions & 0 deletions
37
...ent/core/server/kibana-plugin-server.configdeprecationfactory.unusedfromroot.md
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,37 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) > [unusedFromRoot](./kibana-plugin-server.configdeprecationfactory.unusedfromroot.md) | ||
|
||
## ConfigDeprecationFactory.unusedFromRoot() method | ||
|
||
Remove a configuration property from the root configuration. Will log a deprecation warning if the unused key was found and deprecation applied. | ||
|
||
This should be only used when removing properties from outside of a plugin's configuration. To remove properties from inside a plugin's configuration, use 'unused' instead. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
unusedFromRoot(unusedKey: string): ConfigDeprecation; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| unusedKey | <code>string</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`ConfigDeprecation` | ||
|
||
## Example | ||
|
||
Flags 'somepath.deprecatedProperty' as unused | ||
|
||
```typescript | ||
const provider: ConfigDeprecationProvider = ({ unusedFromRoot }) => [ | ||
unusedFromRoot('somepath.deprecatedProperty'), | ||
] | ||
|
||
``` | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.configdeprecationlogger.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationLogger](./kibana-plugin-server.configdeprecationlogger.md) | ||
|
||
## ConfigDeprecationLogger type | ||
|
||
Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type ConfigDeprecationLogger = (message: string) => void; | ||
``` |
28 changes: 28 additions & 0 deletions
28
docs/development/core/server/kibana-plugin-server.configdeprecationprovider.md
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,28 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) | ||
|
||
## ConfigDeprecationProvider type | ||
|
||
A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md)<!-- -->. | ||
|
||
See [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) for more usage examples. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type ConfigDeprecationProvider = (factory: ConfigDeprecationFactory) => ConfigDeprecation[]; | ||
``` | ||
|
||
## Example | ||
|
||
|
||
```typescript | ||
const provider: ConfigDeprecationProvider = ({ rename, unused }) => [ | ||
rename('oldKey', 'newKey'), | ||
unused('deprecatedKey'), | ||
myCustomDeprecation, | ||
] | ||
|
||
``` | ||
|
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
13 changes: 13 additions & 0 deletions
13
...lopment/core/server/kibana-plugin-server.pluginconfigdescriptor.deprecations.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [PluginConfigDescriptor](./kibana-plugin-server.pluginconfigdescriptor.md) > [deprecations](./kibana-plugin-server.pluginconfigdescriptor.deprecations.md) | ||
|
||
## PluginConfigDescriptor.deprecations property | ||
|
||
Provider for the [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) to apply to the plugin configuration. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
deprecations?: ConfigDeprecationProvider; | ||
``` |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it works as expected. As I understand
settings
is expected to be POJO here. But we passLegacyConfig
https://github.com/elastic/kibana/pull/52251/files#diff-748376502c51ed8bfc271f4a6c4c26d3R251Shouldn't we wrap in
getLegacyRawConfig
or passthis.settings
inlegacy_service
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right. However the PR did not change the arguments we were invoking ClusterManager.create with. So I guess this has always been broken?
The fix is (well, should be) easy
However the legacy service tests are a mess, and are not properly mocking with correct object types (the config in test is actually a
Record
and not aLegacyConfig
). Already had to fix that in #52060, so would be easier to fix in a separate PR once it lands.Will open a ticket for that if it's alright with you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#52860 created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, not a blocker for the current work.