[Fleet] Generate dynamic template mappings for field with wildcard in name#137978
Merged
nchaulet merged 3 commits intoelastic:mainfrom Aug 3, 2022
Merged
Conversation
9a937a9 to
6255698
Compare
Contributor
|
Pinging @elastic/fleet (Team:Fleet) |
kpollich
approved these changes
Aug 3, 2022
Member
kpollich
left a comment
There was a problem hiding this comment.
One minor refactor suggestion otherwise LGTM
| export function processFieldsWithWildcard(fields: Fields): Fields { | ||
| const newFields: Fields = []; | ||
| for (const field of fields) { | ||
| if (field.name.includes('*') && (field.type !== 'object' || !field.object_type)) { |
Member
There was a problem hiding this comment.
This condition may be complex enough to warrant breaking out into a few variables, e.g.
const hasWildcard = field.name.includes('*');
const isObjectField = field.type === 'object' || field.object_type;
if (hasWildcard && !isObjectField) {
// ...
} else {
// ...
}
kpollich
reviewed
Aug 3, 2022
| const newFields: Fields = []; | ||
| for (const field of fields) { | ||
| const hasWildcard = field.name.includes('*'); | ||
| const hasNotObjectType = !field.object_type; |
Member
There was a problem hiding this comment.
This would probably be a bit more sensible as a "positive" condition that's negated below
const hasObjectType = !!field.object_type
if (hasWildcard && !hasObjectType) ...
Member
Author
There was a problem hiding this comment.
yes it make sense, having a bad time naming variables on this one
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Aug 3, 2022
… name (elastic#137978) (cherry picked from commit 88eae3e)
Contributor
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
This was referenced Aug 4, 2022
4 tasks
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.
Description
Resolve #129344
Fleet create datastream mappings based on fields yaml provided by the integration, it was decided that the fields that contains a
*in the name should be installed as dynamic template and not property mappings that PR change that.If a field name contains a
*the field will be transformed to be of typeobjectwith${object_type:field.type}, for example the followed field will be transformed like thisAnd with the work introduced in #137772 this will result in dynamic_templates in the final mappings.
@jsoriano Does it make sense to you?