[dmt] Validate subscribe.apis in package.yaml#370
Open
diyliv wants to merge 5 commits into
Open
Conversation
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the module package.yaml linter rule to validate subscribe.apis entries so that subscribed Kubernetes API references are consistently specified as <group>/<version>/<Kind>, rejecting malformed groups/versions and non-conforming Kind strings. This fits into the module linter’s role of enforcing package metadata correctness early (at lint time) to avoid publishing invalid module packages.
Changes:
- Added
subscribe.apisvalidation to thepackage.yamlrule, including Kubernetes-like validation for API group and version plus aKindformat check. - Added unit tests and rule-level tests covering valid/invalid
subscribe.apisvalues. - Updated the module linter README to document the new validation and error examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pkg/linters/module/rules/package_yaml.go |
Adds subscribe.apis validation logic and helpers (group/version/kind checks). |
pkg/linters/module/rules/package_yaml_test.go |
Adds targeted unit tests for subscribe.apis and integrates cases into rule-level tests. |
pkg/linters/module/README.md |
Documents the new subscribe.apis validation behavior and example errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+289
to
+300
| func validatePackageSubscribeAPI(fieldPath, value string, errorList *errors.LintRuleErrorsList) { | ||
| parts := strings.Split(value, "/") | ||
| if len(parts) != 3 { | ||
| errorList.Errorf("package.yaml %s must use %q format with a non-empty API group", fieldPath, "<group>/<version>/<Kind>") | ||
| return | ||
| } | ||
|
|
||
| group, version, kind := parts[0], parts[1], parts[2] | ||
| if group == "" || version == "" || kind == "" { | ||
| errorList.Errorf("package.yaml %s must use %q format with a non-empty API group", fieldPath, "<group>/<version>/<Kind>") | ||
| return | ||
| } |
Comment on lines
+312
to
+314
| if !isValidSubscribeAPIKind(kind) { | ||
| errorList.Errorf("package.yaml %s kind must be UpperCamelCase and start with an uppercase letter", fieldPath) | ||
| } |
Signed-off-by: diyliv <onlogn081@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
<group>/<version>/<Kind>with a non-empty API group.Kindvalues such as lowercase names inpackage.yaml.subscribe.apisentries.package.yamlvalidation in the module linter README.Example