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

Add elasticsearch mappings definitions into input packages and a key to opt-in to import common definitions #455

Merged
merged 13 commits into from
Dec 22, 2022

Conversation

mrodm
Copy link
Contributor

@mrodm mrodm commented Dec 16, 2022

What does this PR do?

This PR adds support in input packages to include under elasticsearch key dynamic templates and properties (mappings). This PR allows to define elasticsearch.index_template.* keys. It uses the same definition as the data_stream manifests in integration packages.

This PR also adds a new field under _dev/build/build.yml named import_common_dynamic_mappings (other options import_common_mappings?). The aim of this field is to allow developers to opt in to be added automatically by elastic-package
some common definitions needed.

This support would be introduced in package-spec versions >= 2.3.0.

Additional notes:

  • Updated .gitignore to just ignore build folder at the root directory. There are several build folders used in our specs, and git raises some errors because of this:
     $ git add spec/integration/_dev/build/build.spec.yml
    The following paths are ignored by one of your .gitignore files:
    spec/integration/_dev/build
    hint: Use -f if you really want to add them.
    hint: Turn this message off by running
    hint: "git config advice.addIgnoredFile false"
    
  • According to the Jenkins outputs it would be needed to just ignore the one from the root level:
    [2022-11-23T10:15:49.793Z] mkdir -p /var/lib/jenkins/workspace/gest-manager_package-spec_PR-452/src/github.com/elastic/package-spec/build/test-coverage/coverage-unit-report
    [2022-11-23T10:15:49.793Z] mkdir -p /var/lib/jenkins/workspace/gest-manager_package-spec_PR-452/src/github.com/elastic/package-spec/build/test-results
    

Why is it important?

This would allow to elastic-package to add the most common mapping definitions needed to avoid conflicts in mappings for both input and integrations (data_strreams) packages.

Checklist

Related issues

@mrodm mrodm self-assigned this Dec 16, 2022
@elasticmachine
Copy link

elasticmachine commented Dec 16, 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-12-20T14:55:04.625+0000

  • Duration: 9 min 32 sec

Test stats 🧪

Test Results
Failed 0
Passed 678
Skipped 0
Total 678

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

@elasticmachine
Copy link

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (7/7) 💚
Files 68.0% (17/25) 👍
Classes 76.471% (26/34) 👍
Methods 56.075% (60/107) 👍
Lines 42.229% (538/1274) 👍
Conditionals 100.0% (0/0) 💚

@@ -28,6 +28,7 @@ func TestValidateFile(t *testing.T) {
}{
"good": {},
"good_v2": {},
"good_input": {},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a new good_input package to add these keys. It is copied from the sql_input test package.

@@ -1,4 +1,4 @@
format_version: 2.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update version in good_v2 to allow adding the new field in _dev/build/build.yml

@mrodm mrodm marked this pull request as ready for review December 20, 2022 10:30
@mrodm mrodm requested a review from a team as a code owner December 20, 2022 10:30
@mrodm mrodm requested a review from hop-dev December 20, 2022 10:30
patch:
- op: remove
path: "/properties/dependencies/properties/ecs/properties/import_common_dynamic_mappings"
Copy link
Member

Choose a reason for hiding this comment

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

👍 this will encourage users of this to update the format of their packages 🙂

@@ -20,7 +20,17 @@ spec:
type: string
description: Source reference
pattern: '^git@.+'
import_common_dynamic_mappings:
Copy link
Member

Choose a reason for hiding this comment

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

Nit. common looks redundant here.

Suggested change
import_common_dynamic_mappings:
import_dynamic_mappings:

Copy link
Member

Choose a reason for hiding this comment

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

And maybe dynamic too, this feature imports mappings for this schema, they happen to be mostly dynamic, but could be static too.

Suggested change
import_common_dynamic_mappings:
import_mappings:

Or:

Suggested change
import_common_dynamic_mappings:
import_template:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not totally sure about this name. Agreed that common does not provide any value to the name.
I will update this field to be import_mappings

Thanks!

spec/changelog.yml Show resolved Hide resolved
@mrodm mrodm requested a review from jsoriano December 20, 2022 18:03
Copy link
Contributor

@hop-dev hop-dev left a comment

Choose a reason for hiding this comment

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

Addition of the elasticsearch key at the top level of input packages looks good to me 👍 Thanks for this Mario!

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.

4 participants