Refactor schema reader to use intermediate schema structure#722
Merged
marshallmain merged 4 commits intoelastic:masterfrom Jan 21, 2020
Merged
Refactor schema reader to use intermediate schema structure#722marshallmain merged 4 commits intoelastic:masterfrom
marshallmain merged 4 commits intoelastic:masterfrom
Conversation
webmat
reviewed
Jan 17, 2020
Contributor
webmat
left a comment
There was a problem hiding this comment.
Thanks for this, @marshallmain! This is looking great :-)
- Could you add back a few tests? They don't need to cover all edge cases, but perhaps 1 or 2 tests exercising each of
flatten_fieldsandcleanup_fields_recursive. - Please add a changelog entry to the "tooling" section
| 1.5.0-dev,true,client,client.as.number,long,extended,15169,Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. | ||
| 1.5.0-dev,true,client,client.as.organization.name,keyword,extended,Google LLC,Organization name. | ||
| 1.5.0-dev,true,client,as.organization.name.text,text,extended,Google LLC,Organization name. | ||
| 1.5.0-dev,true,client,client.as.organization.name.text,text,extended,Google LLC,Organization name. |
Contributor
There was a problem hiding this comment.
Hadn't noticed that before.
PRs that come with bugfixes are my favourites ;-)
Contributor
|
Once we're done with this PR we should revisit #698 |
Contributor
Author
|
Thanks for the review @webmat ! I'm planning to add the tests and changelog tomorrow so we can get this merged. |
webmat
approved these changes
Jan 21, 2020
Contributor
webmat
left a comment
There was a problem hiding this comment.
Looking great, thanks for adding the tests 👍
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR improves the ECS ability to nest reusable fields inside other reusable field sets. Currently there is at least one example of multiple reuse: "group" fields are reused in "user", and "user" is then reused by "client", "destination", "host", "server", and "source". However, the implementation in master depends on the "group" fields being copied to "user" before all of the "user" fields are copied to the final locations. This works because the "group" key comes before the "user" key when iterating over the keys in the schema dictionary, but this will not be the case for other places we might want to use multi-level nesting.
This PR adds an intermediate data structure representing the schema which contains references to reused field sets rather than immediately copying them. Using references removes the dependency on the order fieldsets are read in. The intermediate representation is then rendered into the same formats as before by recursively replacing the references with copies.
The output from the refactored version diverges from the original in a few ways. Most notably original_fieldset now refers to the closest reusable fieldset (previously client.user.group.domain would have original_fieldset: user instead of original_fieldset: group). original_fieldset is also populated in every reusable fieldset, even when the fieldset is not embedded. dashed_name now matches flat_name more closely.
Reopened version of #707 reapplying changes on top of master