-
Notifications
You must be signed in to change notification settings - Fork 90
Add source and build validation modes #1175
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
Closed
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e1a0cb2
Update .gitignore to include .scratch directory
teresaromero 08356fa
Add internal Mode scaffolding for validation modes
teresaromero 135f03a
Add public constructor API with mode-aware validators (task 02)
teresaromero 9d454d5
Add source mode: tag source-only rules and reject _embedded_ecs (task…
teresaromero 50cc670
Add build mode: _dev/ rejection + good_built fixture (task 04)
teresaromero d8a368f
Add build mode: .link file rejection (task 05)
teresaromero 138fa63
Add build mode: external: ecs field rejection (task 06)
teresaromero d827f09
Add build mode: stream input materialization rejection (task 07)
teresaromero 2eda0ed
Add changelog entry for validation modes (task 08)
teresaromero 6ac4740
Fix listDataStreams to skip non-directory entries under data_stream/
teresaromero 3c23271
Fix bad_built fixture names and mid-name .link test case (review B1, B2)
teresaromero 9827ff2
Fix medium-priority review items (S2, T1, T2)
teresaromero d6573c2
Fix correctness and cleanup issues found in code review
teresaromero 2a2f388
Update changelog link to PR #1175
teresaromero 14cc75c
Fix lint: add godoc comments to exported modes package symbols
teresaromero 9c3e702
Add eager path/fs validation to NewFromPath and NewFromFS constructors
teresaromero 460165a
Skip template validation for composable streams with no local templates
teresaromero 7242f16
Skip template validation for composable policy template inputs with n…
teresaromero 411b8f8
Allow partial var definitions on composable streams and policy templa…
teresaromero 498dbf2
Restrict SVR00010 (input qualifier) to build mode only
teresaromero 440ecd0
Enhance validation error handling and mode checks
teresaromero 703e088
Address PR review comments
teresaromero a960b91
Use package-relative path in manifest read error
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,5 @@ fuzz | |
| /build/ | ||
| .vscode/ | ||
| .DS_Store | ||
|
|
||
| .scratch/ | ||
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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License; | ||
| // you may not use this file except in compliance with the Elastic License. | ||
|
|
||
| package modes | ||
|
|
||
| // Mode represents the validation mode used when validating a package. | ||
| type Mode string | ||
|
|
||
| // Validation modes. The public API re-exports these as validator.Mode* constants. | ||
| const ( | ||
| Legacy Mode = "legacy" | ||
| Source Mode = "source" | ||
| Build Mode = "build" | ||
| ) | ||
|
|
||
| // Valid reports whether m is a recognised validation mode. | ||
| func (m Mode) Valid() bool { | ||
| switch m { | ||
| case Legacy, Source, Build: | ||
| return true | ||
| } | ||
| return false | ||
| } | ||
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
39 changes: 39 additions & 0 deletions
39
code/go/internal/validator/semantic/validate_no_dev_folder.go
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License; | ||
| // you may not use this file except in compliance with the Elastic License. | ||
|
|
||
| package semantic | ||
|
|
||
| import ( | ||
| "io/fs" | ||
|
|
||
| "github.com/elastic/package-spec/v3/code/go/internal/fspath" | ||
| "github.com/elastic/package-spec/v3/code/go/pkg/specerrors" | ||
| ) | ||
|
|
||
| // ValidateNoDevFolder errors for any _dev/ directory found in the package. | ||
| // _dev/ is a source-only artifact used during development (tests, deploy | ||
| // configs, build manifests). It must not appear in a built package that is | ||
| // validated with ModeBuild. | ||
| func ValidateNoDevFolder(fsys fspath.FS) specerrors.ValidationErrors { | ||
| var errs specerrors.ValidationErrors | ||
| walkErr := fs.WalkDir(fsys, ".", func(p string, d fs.DirEntry, err error) error { | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if d.IsDir() && d.Name() == "_dev" { | ||
| errs = append(errs, specerrors.NewStructuredErrorf( | ||
| "file %q: _dev directory is not allowed in built packages", | ||
| fsys.Path(p), | ||
| )) | ||
| // Skip the subtree to avoid generating child errors for each | ||
| // file inside the _dev directory. | ||
| return fs.SkipDir | ||
| } | ||
| return nil | ||
| }) | ||
| if walkErr != nil { | ||
| errs = append(errs, specerrors.NewStructuredError(walkErr, specerrors.UnassignedCode)) | ||
| } | ||
| return errs | ||
| } |
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.
We originally discussed that legacy was functionally equivalent to source mode, but then there was some additional discussion about maybe keeping it for some time until we deprecate it and it collapses into source by default. Just wanted to see what the plan was here and if we really even need legacy at all if theyre functionally eq.
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.
I've kept it for the shake of migrating. I felt it was safer to have all options available when using it on elastic-package. We could have a followup cleanup issue to remove it.