Skip to content
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

Import ecs fields from the ecs_nested.yml source file #766

Merged
merged 8 commits into from
Mar 31, 2022

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Mar 29, 2022

Import ECS fields from ecs/ecs_nested.yml instead of from beats/fields.ecs.yml.

Beats fields don't include all the information provided by ECS, for example they don't include the normalize rules, required for #615. I guess this can be expected, as there can be features of ECS that are not used or needed in Beats, but could be used by other tools.

ecs_nested.yml takes into account where nested objects can be reused. This fixes #750.

@jsoriano jsoriano added the Team:Ecosystem Label for the Packages Ecosystem team label Mar 29, 2022
@jsoriano jsoriano self-assigned this Mar 29, 2022
@@ -1,6 +1,4 @@
- name: destination.geo.location
external: ecs
- name: geo.location
external: ecs
Copy link
Member Author

Choose a reason for hiding this comment

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

This field is actually invalid, as reported in #750.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 29, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-03-31T08:48:50.322+0000

  • Duration: 25 min 10 sec

Test stats 🧪

Test Results
Failed 0
Passed 622
Skipped 0
Total 622

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@jsoriano
Copy link
Member Author

/test

@jsoriano jsoriano marked this pull request as draft March 30, 2022 09:25
@jsoriano jsoriano changed the title Import ecs fields from the ecs_flat.yml source file Import ecs fields from the ecs_nested.yml source file Mar 30, 2022
@jsoriano jsoriano marked this pull request as ready for review March 30, 2022 12:13
@jsoriano jsoriano requested a review from a team March 30, 2022 12:13
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM, but to be honest we should get rid of this script as soon as possible. I don't know what is the percentage of migration completeness.

@jsoriano
Copy link
Member Author

LGTM, but to be honest we should get rid of this script as soon as possible. I don't know what is the percentage of migration completeness.

@mtojek take into account that this is for the fields imported for the external: ecs property, not for the information imported from beats.

The mention to beats is because before this change we are using the ecs fields document generated for beats (like this one), and after this change we would be using one of the generic ones (like this one). This way we can import anything from the ECS definitions, and not only what is relevant to Beats.

I guess we don't want to get rid of external: ecs 🙂

case yaml.MappingNode:
// Fields are defined as a map, this happens in ecs fields files.
var fields []FieldDefinition
for i := 0; i < len(value.Content); i += 2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it safe to assume it's always a pair? Is there a chance that it will become a triple :)? a comment, or second value...

Copy link
Member Author

@jsoriano jsoriano Mar 31, 2022

Choose a reason for hiding this comment

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

In principle yes, the content of a mapping node should be pairs of key/values. Comments are included in the significative nodes themselves.

But let me add an additional constraint here to avoid reading the last i+1 value when it doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in c79194b.

@mtojek mtojek self-requested a review March 31, 2022 08:51
@jsoriano jsoriano merged commit 7869bd5 into elastic:main Mar 31, 2022
@jsoriano jsoriano deleted the import-ecs-flat-fields branch March 31, 2022 14:41
mtojek pushed a commit to mtojek/elastic-package that referenced this pull request Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Ecosystem Label for the Packages Ecosystem team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lint] fail when referencing ECS fields outside of allowed field reuse locations
3 participants