mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* [deprecations] convert flattened settings to nested settings * [deprecations] reuse rename method for elasticsearch.url to elasticsearch.hosts * newline * add known issues to docs
This commit is contained in:
parent
890b2c00ec
commit
f60e17d2c6
2 changed files with 42 additions and 3 deletions
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { difference } from 'lodash';
|
||||
import { difference, get, set } from 'lodash';
|
||||
import { transformDeprecations } from './transform_deprecations';
|
||||
import { unset, formatListAsProse, getFlattenedObject } from '../../utils';
|
||||
import { getTransform } from '../../deprecation';
|
||||
|
@ -39,9 +39,13 @@ async function getUnusedConfigKeys(
|
|||
const { spec } = plugins[i];
|
||||
const transform = await getTransform(spec);
|
||||
const prefix = spec.getConfigPrefix();
|
||||
const pluginSettings = settings[prefix];
|
||||
|
||||
// nested plugin prefixes (a.b) translate to nested objects
|
||||
const pluginSettings = get(settings, prefix);
|
||||
if (pluginSettings) {
|
||||
settings[prefix] = transform(pluginSettings);
|
||||
// flattened settings are expected to be converted to nested objects
|
||||
// a.b = true => { a: { b: true }}
|
||||
set(settings, prefix, transform(pluginSettings));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,41 @@ describe('server/config completeMixin()', function () {
|
|||
|
||||
await expect(callCompleteMixin()).resolves.toBe(undefined);
|
||||
});
|
||||
|
||||
it('should transform deeply nested deprecated plugin settings', async () => {
|
||||
const { callCompleteMixin } = setup({
|
||||
settings: {
|
||||
xpack: {
|
||||
monitoring: {
|
||||
elasticsearch: {
|
||||
url: 'http://localhost:9200'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
configValues: {
|
||||
xpack: {
|
||||
monitoring: {
|
||||
elasticsearch: {
|
||||
hosts: 'http://localhost:9200'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
spec: {
|
||||
getDeprecationsProvider() {
|
||||
return async ({ rename }) => [rename('elasticsearch.url', 'elasticsearch.hosts')];
|
||||
},
|
||||
getConfigPrefix: () => 'xpack.monitoring'
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
await expect(callCompleteMixin()).resolves.toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('disabled plugins', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue