Skip to content

Add spec for shared folder and link files #888

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

Merged
merged 31 commits into from
Apr 9, 2025

Conversation

marc-gr
Copy link
Contributor

@marc-gr marc-gr commented Apr 1, 2025

What does this PR do?

Adds a spec definition for a shared folder under _dev that will allow users to put in there any files that are going to be linked from multiple data_streams and/or packages.

Adds a spec definition to allow *.link files under pipelines, agent, and fields to let users reuse repeated files from other parts of the integrations repository.

Adds a test package for both.

Checklist

Related issues

@marc-gr marc-gr requested a review from a team as a code owner April 1, 2025 10:49
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

I think that we should take into account the linked files in validations, though they will be taken into account when the package is built, so probably not a blocker till we have more specific validation of source vs. built packages.

Apart from that, I wonder if we should include checksums in the files tested here 🤔

@marc-gr marc-gr marked this pull request as draft April 2, 2025 10:50
@marc-gr marc-gr marked this pull request as ready for review April 2, 2025 13:07
@marc-gr
Copy link
Contributor Author

marc-gr commented Apr 2, 2025

Added the logic to be able to do the checks here. I am not sure about what to do with the FindRoot... functionality as it is used in both here and elastic-package, but does not really makes sense to me to have it in here other than that. For now I duplicated it but open to suggestions.

I also updated elastic/elastic-package#2483 to make use of the changes

@marc-gr marc-gr requested review from jsoriano and mrodm April 2, 2025 13:10
@marc-gr
Copy link
Contributor Author

marc-gr commented Apr 4, 2025

I simplified this as suggested:

  • Only logic in package-spec is now related to finding the included files on validation
  • Removes any extra logic and does this transparently using a custom fs.FS
  • As suggested in Simple includes implementation elastic-package#2483 now included files are relative to the link location

For this to be effective I had to set required: false to agent and fields specs. This is not ideal but I am not sure how to add an anyOf condition in there. I see a similar case in https://github.com/elastic/package-spec/blob/main/spec/integration/elasticsearch/spec.yml#L24 and as far as I can tell it does not seem addressed either, so any suggestions in that direction are appreciated.

I think once we solve that this seems enough from the spec perspective.

@marc-gr marc-gr requested review from jsoriano and mrodm April 4, 2025 09:56
@marc-gr
Copy link
Contributor Author

marc-gr commented Apr 4, 2025

@mrodm I added a semantic check for our case and the pipelines one, not sure this is the way you prefer them to be defined so lmk if any changes are required

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Overall looks good, thanks for adding the suggestions. Added some small questions.

// It checks the following paths:
// - agent/input
// - agent/stream
// - fields
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remark that this fields folder is just for the ones defined under data_stream ? Is that right?

If so, would it be better to re-phrase that item in the comment as this? WDYT @marc-gr ?

Suggested change
// - fields
// - data_stream/*/fields

IIUC the fields folder in transforms is not taken into account here. If it would be needed those links in transforms, I guess it could be added support in a follow-up. Let's continue with the current links defined in this PR , is that ok @jsoriano?

@marc-gr
Copy link
Contributor Author

marc-gr commented Apr 8, 2025

@mrodm I opted to add an allowLink option into the item spec after discussing it with @jsoriano as it seems more robust and not rely on the semantic validation, I think this is a cleaner approach together with the custom fs

@marc-gr marc-gr requested review from jsoriano and mrodm April 8, 2025 13:10
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

I opted to add an allowLink option into the item spec after discussing it with @jsoriano as it seems more robust and not rely on the semantic validation, I think this is a cleaner approach together with the custom fs.

Thanks for trying this approach, it looks clearer and I feel more confident merging this. I think there can still be some corner cases, but they will be more limited.

I think this could be merged, but added a couple of questions.
Before merging I would like to double-check what parts of linkedfiles we want/need to publicly expose.

@marc-gr marc-gr requested a review from jsoriano April 9, 2025 08:35
jsoriano
jsoriano previously approved these changes Apr 9, 2025
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines +21 to +26
- description: Add support for _dev/shared folder.
type: enhancement
link: https://github.com/elastic/package-spec/pull/888
- description: Add support for *.link files in agent, pipelines, and fields folders.
type: enhancement
link: https://github.com/elastic/package-spec/pull/888
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved to a new version block for 3.3.6-next.

@elasticmachine
Copy link

💚 Build Succeeded

History

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Thanks! 🎉

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

Thanks!

@jsoriano jsoriano merged commit 851b65d into elastic:main Apr 9, 2025
3 checks passed
@marc-gr marc-gr deleted the feat/includes branch April 9, 2025 14:31
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.

Support for shared fields mapping and pipelines between data streams
4 participants