-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate kibana.autocomplete config to data plugin (#100586)
* Migrate kibana.autocomplete config to data plugin * Fix CI * Fix tests Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
f58ddc4
commit 8edb316
Showing
20 changed files
with
134 additions
and
100 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
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
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,71 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { cloneDeep } from 'lodash'; | ||
|
||
import { applyDeprecations, configDeprecationFactory } from '@kbn/config'; | ||
|
||
import { autocompleteConfigDeprecationProvider } from './config_deprecations'; | ||
|
||
const applyConfigDeprecations = (settings: Record<string, any> = {}) => { | ||
const deprecations = autocompleteConfigDeprecationProvider(configDeprecationFactory); | ||
const deprecationMessages: string[] = []; | ||
const migrated = applyDeprecations( | ||
settings, | ||
deprecations.map((deprecation) => ({ | ||
deprecation, | ||
path: '', | ||
})), | ||
() => ({ message }) => deprecationMessages.push(message) | ||
); | ||
return { | ||
messages: deprecationMessages, | ||
migrated: migrated.config, | ||
}; | ||
}; | ||
|
||
describe('Config Deprecations', () => { | ||
it('does not report deprecations for default configuration', () => { | ||
const defaultConfig = { data: { autocomplete: { valueSuggestions: {} } } }; | ||
const { messages, migrated } = applyConfigDeprecations(cloneDeep(defaultConfig)); | ||
expect(migrated).toEqual(defaultConfig); | ||
expect(messages).toHaveLength(0); | ||
}); | ||
|
||
it('renames kibana.autocompleteTerminateAfter to data.autocomplete.valueSuggestions.terminateAfter', () => { | ||
const config = { | ||
kibana: { | ||
autocompleteTerminateAfter: 123, | ||
}, | ||
}; | ||
const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); | ||
expect(migrated.kibana.autocompleteTerminateAfter).not.toBeDefined(); | ||
expect(migrated.data.autocomplete.valueSuggestions.terminateAfter).toEqual(123); | ||
expect(messages).toMatchInlineSnapshot(` | ||
Array [ | ||
"\\"kibana.autocompleteTerminateAfter\\" is deprecated and has been replaced by \\"data.autocomplete.valueSuggestions.terminateAfter\\"", | ||
] | ||
`); | ||
}); | ||
|
||
it('renames kibana.autocompleteTimeout to data.autocomplete.valueSuggestions.timeout', () => { | ||
const config = { | ||
kibana: { | ||
autocompleteTimeout: 123, | ||
}, | ||
}; | ||
const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); | ||
expect(migrated.kibana.autocompleteTimeout).not.toBeDefined(); | ||
expect(migrated.data.autocomplete.valueSuggestions.timeout).toEqual(123); | ||
expect(messages).toMatchInlineSnapshot(` | ||
Array [ | ||
"\\"kibana.autocompleteTimeout\\" is deprecated and has been replaced by \\"data.autocomplete.valueSuggestions.timeout\\"", | ||
] | ||
`); | ||
}); | ||
}); |
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,19 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { ConfigDeprecationProvider } from 'src/core/server'; | ||
|
||
export const autocompleteConfigDeprecationProvider: ConfigDeprecationProvider = ({ | ||
renameFromRoot, | ||
}) => [ | ||
renameFromRoot( | ||
'kibana.autocompleteTerminateAfter', | ||
'data.autocomplete.valueSuggestions.terminateAfter' | ||
), | ||
renameFromRoot('kibana.autocompleteTimeout', 'data.autocomplete.valueSuggestions.timeout'), | ||
]; |
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
Oops, something went wrong.