Skip to content

Refactor schema reader to use intermediate schema structure #707

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

Closed

Conversation

marshallmain
Copy link
Contributor

@marshallmain marshallmain commented Dec 20, 2019

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.

TODO: add/update tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant