-
Notifications
You must be signed in to change notification settings - Fork 90
Validation rules: build/source mode enforcement #1178
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
teresaromero
merged 51 commits into
elastic:main
from
teresaromero:549-validation-semantic
Jun 18, 2026
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
c2b6ed7
Update .gitignore to include .scratch directory
teresaromero 1166296
Add internal Mode scaffolding for validation modes
teresaromero 892c661
Add public constructor API with mode-aware validators (task 02)
teresaromero a5c8cfc
Add eager path/fs validation to NewFromPath and NewFromFS constructors
teresaromero 30cfd76
Fix API: NewFromZip drops mode param, NewFromFS ModeSource uses linke…
teresaromero d482f31
Fix lint: add godoc comments to exported modes package symbols
teresaromero 2769edc
Add mode.Valid() guard in NewSpec and improve Validate() closer error…
teresaromero 324c4a0
Fix TestLegacyPreservation_FromZip to match NewFromZip signature change
teresaromero d999602
Add support for mode-aware constructors and validation APIs in changelog
teresaromero fe83a0a
Address PR review: fix API semantics, tests, and remove private newFr…
teresaromero 491658c
Fix TestNewFromZip_ConstructorSucceeds file handle leak on Windows
teresaromero 15750f5
Update .gitignore to remove .scratch directory entry
teresaromero fcaf8c2
Refactor Validator constructors to remove Option parameter
teresaromero f4e266e
refactor POV on modes validation
teresaromero e9d0013
remove unused public mode
teresaromero cbd3b7c
Improve documentation for validation API and modes
teresaromero 0f275c0
Add unit tests for mode validation
teresaromero d1efd03
Add integration tests for link file behavior across validation modes
teresaromero 4233331
Remove unused test case for package validation without links in TestL…
teresaromero da2a325
Remove wrapping around specFn
teresaromero 8539209
Restore Option C Validator API with mode-embedded FS and fix link blo…
teresaromero b0049ff
Improve godoc comments for validation modes API
teresaromero d4508b1
Add copyright notice to modes.go file
teresaromero 8d441f1
Move modes into internal validator pkg
teresaromero 15cc91e
Refactor validator API to streamline mode handling
teresaromero cc5e273
Remove modes.go file and consolidate mode definitions in validator.go
teresaromero 2a3fef8
Add comprehensive tests for ValidateFromFS and ValidateFromZip methods
teresaromero d8a2a6c
Refactor validation mode constants for clarity and consistency
teresaromero ebac0c7
Refactor validator instantiation to unify creation method
teresaromero d895e49
Add logging for validation mode in technical preview
teresaromero 6fd467f
Merge branch '549-validation-api' of github.com:teresaromero/package-…
teresaromero 2abdb49
Add structured error handling for validation mode warnings
teresaromero ab9ad08
Merge branch '549-validation-api' of github.com:teresaromero/package-…
teresaromero 73326a2
Add build/source mode semantic validations and composable package sup…
teresaromero 9345254
Fix stale NewFromZip comment and bad_built_missing_input README
teresaromero cc99311
Remove unnecessary ErrUnsupportedLinkFile suppression from validateFile
teresaromero 0c34f3f
Update validation rules to include Legacy mode for integration inputs…
teresaromero 7b72caf
Add godoc comment to helper
teresaromero 561b526
Fix fixture isolation, add e2e source-mode tests, and update changelo…
teresaromero 8ccac7b
Merge bad_built_with_dev and bad_built_with_link into bad_built_fs_ar…
teresaromero 148aebf
Refactor TestBuildModeValidation to follow file test-table conventions
teresaromero 8c60420
Remove redundant package guard from validateIntegrationPolicyTemplate…
teresaromero a52f51a
Address PR nits: rename Materialized→Bundled, simplify comment, move …
teresaromero 5b78784
Remove test/packages/build_mode now that fixtures live in test/built_…
teresaromero 44f5383
Change ValidateNoExternalEcs to ValidateNoExternalFields
teresaromero b66a1f3
Enforce _dev/ source-only constraint via spec instead of semantic walk
teresaromero 4206c50
Enforce .link source-only constraint via folder validator instead of …
teresaromero dedc2ff
Remove redundant missing-input check from ValidateStreamInputBundled
teresaromero c29ab54
Update TestValidateNoExternalFields to ensure consistent error expect…
teresaromero 2fdf404
Replace sourceOnly bool with validationMode string in item spec
teresaromero 1219cd3
Fix validationMode gaps: enum validation, file enforcement, consisten…
teresaromero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,11 @@ import ( | |
|
|
||
| const ( | ||
| defaultStreamTemplatePath = "stream.yml.hbs" | ||
| packageTypeIntegration = "integration" | ||
| ) | ||
|
|
||
| type policyTemplateInput struct { | ||
| Type string `yaml:"type"` | ||
| Package string `yaml:"package"` | ||
| TemplatePath string `yaml:"template_path"` | ||
| TemplatePaths []string `yaml:"template_paths"` | ||
| } | ||
|
|
@@ -41,6 +41,7 @@ type integrationPackageManifest struct { // package manifest | |
|
|
||
| type stream struct { | ||
| Input string `yaml:"input"` | ||
| Package string `yaml:"package"` | ||
| TemplatePath string `yaml:"template_path"` | ||
| TemplatePaths []string `yaml:"template_paths"` | ||
| } | ||
|
|
@@ -78,7 +79,7 @@ func ValidateIntegrationPolicyTemplates(fsys fspath.FS) specerrors.ValidationErr | |
| specerrors.NewStructuredErrorf("file \"%s\" is invalid: %w", fsys.Path(manifestPath), errFailedToParseManifest)} | ||
| } | ||
|
|
||
| if manifest.Type != packageTypeIntegration { | ||
| if manifest.Type != integrationPackageType { | ||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -110,6 +111,9 @@ func ValidateIntegrationPolicyTemplates(fsys fspath.FS) specerrors.ValidationErr | |
| // under agent/input when template_paths or template_path is set (Fleet: template_paths first). | ||
| func validateIntegrationPolicyTemplateInputs(fsys fspath.FS, policyTemplate integrationPolicyTemplate) error { | ||
| for _, input := range policyTemplate.Inputs { | ||
| // Only validate template files that are explicitly declared; if none are set there | ||
| // is nothing to check (composable inputs without overlay templates source them from | ||
| // the dependency package, which is absent from the source tree). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for making these comments more concise 👍 |
||
| if len(input.TemplatePaths) > 0 { | ||
| for _, tp := range input.TemplatePaths { | ||
| if err := validateAgentInputTemplatePath(fsys, tp); err != nil { | ||
|
|
@@ -141,6 +145,11 @@ func validateAllDataStreamStreamTemplates(fsys fspath.FS, dsMap map[string]dataS | |
| dsManifestPath := path.Join(dsDir, "manifest.yml") | ||
| manifest := dsMap[dsDir] | ||
| for _, s := range manifest.Streams { | ||
| // Don't validate template paths if they use a package as input | ||
| // and they don't define any template. | ||
| if s.Package != "" && s.TemplatePath == "" && len(s.TemplatePaths) == 0 { | ||
| continue | ||
| } | ||
| if err := validateSingleDataStreamStreamTemplates(fsys, dsDir, s); err != nil { | ||
| errs = append(errs, specerrors.NewStructuredErrorf( | ||
| "file \"%s\" is invalid: data stream \"%s\" stream input %q: %w", | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation of this change? Can we have anything under
dataStreamDirthat is not a directory?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the spec definition there are only directories on the datastream dir, but, fs.ReadDir is gathering directories and files, so i thought it was interesting to add this guard at this layer to ensure it. based on the docs https://pkg.go.dev/io/fs#DirEntry the direntry interface could be one or the other...