Skip to content

[EPM] Adding support for nested fields#64829

Merged
jonathan-buttner merged 6 commits intoelastic:masterfrom
jonathan-buttner:add-nested-enabled
Apr 30, 2020
Merged

[EPM] Adding support for nested fields#64829
jonathan-buttner merged 6 commits intoelastic:masterfrom
jonathan-buttner:add-nested-enabled

Conversation

@jonathan-buttner
Copy link
Copy Markdown
Contributor

@jonathan-buttner jonathan-buttner commented Apr 29, 2020

This PR adds support for a couple things:

  • Adds support for nested field types to be merged with group
  • Allows fields like (dynamic, enabled, etc) to be placed on a group type if it was merged with a top level object or nested type

Testing

I added more tests to cover the additional cases with nested types.

image

@jonathan-buttner jonathan-buttner added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project v7.8.0 Team:Fleet Team label for Observability Data Collection Fleet team labels Apr 29, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/ingest-management (Feature:EPM)

// only merge if found is a group and field is object, nested, or group.
// Or if found is object, or nested, and field is a group.
// This is to avoid merging two objects, or nested, or object with a nested.
(found.type === 'group' &&
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skh @ruflin let me know if you have suggestions for cleaning this logic up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I'm fine with it, especially with all the comments you added.

I'd suggest adding an issue in the kibana repo for beta1 to revisit dedupFields() after alpha1, fully specify it's behavior (see also elastic/package-registry#340 ) and verify that it handles all edge cases correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, here's the issue: #64901

@jonathan-buttner jonathan-buttner marked this pull request as ready for review April 29, 2020 19:59
@jonathan-buttner jonathan-buttner requested review from a team, ruflin and skh April 29, 2020 19:59
scaling_factor?: number;
dynamic?: 'strict' | boolean;
include_in_parent?: boolean;
include_in_root?: boolean;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch (type) {
case 'group':
fieldProps = generateMappings(field.fields!);
attemptAddDynamicAndEnabled(fieldProps, field);
Copy link
Copy Markdown
Contributor

@skh skh Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for factoring this out into a separate helper function.

Could we not mutate the input parameter fieldProps in these calls? In other places we return a (mutated) copy, so that line would read

fieldProps = attemptAddDynamicAndEnabled(fieldProps, field);

and it is more readable when we stay consistent throughout the code base.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I updated to keep it similar with the other cases.

Copy link
Copy Markdown
Contributor

@skh skh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this! I have one request about not mutating function input, see inline comment.

Apart from that this looks good to me -- we'll probably want to revisit dedupFields() once we found out all the other things it needs to do, but we don't have to do it now.

@skh skh self-requested a review April 30, 2020 14:15
Copy link
Copy Markdown
Contributor

@skh skh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jonathan-buttner jonathan-buttner merged commit a7291fa into elastic:master Apr 30, 2020
@jonathan-buttner jonathan-buttner deleted the add-nested-enabled branch April 30, 2020 17:03
jonathan-buttner added a commit that referenced this pull request May 4, 2020
* Allowing nested types to be merged with group

* Adding nested to case and handling other fields

* Cleaing up if logic

* Removing unneeded if statement

* Adding nested type to switch and more tests

* Keeping functions immutable

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.8.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants