mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Config] Fix handling of splittable subkeys when processing values (#190590)
## Summary Follow up from https://github.com/elastic/kibana/pull/178841 ## Release note We fixed a bug when processing YAML configuration that contains dotted notation in objects in arrays. This can manifest as a validation error causing Kibana to not start.
This commit is contained in:
parent
2e7d67f893
commit
90a435cf8f
3 changed files with 37 additions and 1 deletions
7
packages/kbn-config/src/__fixtures__/unsplittable_3.yml
Normal file
7
packages/kbn-config/src/__fixtures__/unsplittable_3.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
'[foo.bar]': "foobar"
|
||||
list:
|
||||
- id: "id1"
|
||||
'[a.b]': ['foo', 'bar']
|
||||
test.this.out: ['foo', 'bar']
|
||||
|
|
@ -131,6 +131,33 @@ test('supports unsplittable key syntax on nested list', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
test('supports unsplittable key syntax on nested list with splittable subkeys', () => {
|
||||
const config = getConfigFromFiles([fixtureFile('/unsplittable_3.yml')]);
|
||||
|
||||
expect(config).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"foo.bar": "foobar",
|
||||
"list": Array [
|
||||
Object {
|
||||
"a.b": Array [
|
||||
"foo",
|
||||
"bar",
|
||||
],
|
||||
"id": "id1",
|
||||
"test": Object {
|
||||
"this": Object {
|
||||
"out": Array [
|
||||
"foo",
|
||||
"bar",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('supports var:default syntax', () => {
|
||||
process.env.KBN_ENV_VAR1 = 'val1';
|
||||
|
||||
|
|
|
@ -59,7 +59,9 @@ function processEntryValue(value: any) {
|
|||
delete value[subKey];
|
||||
set(value, [unsplitKey], processEntryValue(subVal));
|
||||
} else {
|
||||
set(value, subKey, processEntryValue(subVal));
|
||||
const subKeySplits = splitKey(subKey);
|
||||
if (subKeySplits.length > 1) delete value[subKey];
|
||||
set(value, subKeySplits, processEntryValue(subVal));
|
||||
}
|
||||
}
|
||||
} else if (typeof value === 'string') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue