-
Notifications
You must be signed in to change notification settings - Fork 51
feat: Enhance nomos vet with flag validation and raw resource processing #1926
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
base: main
Are you sure you want to change the base?
feat: Enhance nomos vet with flag validation and raw resource processing #1926
Conversation
|
Hi @cowsking. Thanks for your PR. I'm waiting for a GoogleContainerTools member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Summary of ChangesHello @cowsking, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Code Review
This pull request enhances the nomos vet command by introducing a --no-api-server-check-for-group flag to skip API server validation for specific resource groups, which resolves an issue with OPA Gatekeeper resources. The changes include adding the new flag, implementing validation to ensure it's not used with the existing --no-api-server-check flag, and updating the resource processing logic to respect the new flag. The accompanying tests are a good addition. My review includes a critical fix to prevent unintended error suppression and a suggestion to improve test robustness.
|
/ok-to-test |
|
@cowsking: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
d866819 to
579caba
Compare
|
/ok-to-test |
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.
Pull Request Overview
This PR introduces a new flag --no-api-server-check-for-group to skip API server validation for specific API groups, providing a more granular alternative to the existing --no-api-server-check flag. This is particularly useful for scenarios like Gatekeeper constraint templates where the GVK may not be discoverable but should still be validated.
- Added a new utility package
gvkutilfor parsing and matching GroupKind patterns - Implemented flag exclusivity validation to prevent simultaneous use of both flags
- Integrated the new flag into the validation flow to skip errors for matching GVKs
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/util/gvkutil/gvk.go | New utility for parsing group patterns and matching GroupKind objects |
| pkg/util/gvkutil/gvk_test.go | Test coverage for the new gvkutil package |
| pkg/validate/fileobjects/raw.go | Integrated gvkutil to skip errors for matching GVKs during validation |
| cmd/nomos/flags/flags.go | Added the new --no-api-server-check-for-group flag definition |
| cmd/nomos/vet/vet.go | Added PreRunE validation to ensure flag exclusivity |
| cmd/nomos/vet/vet_test.go | Tests for flag exclusivity validation |
| e2e/testdata/gatekeeper-skip-gvk/constraint.yaml | Test data for Gatekeeper constraint |
| e2e/testdata/gatekeeper-skip-gvk/constraint-template.yaml | Test data for Gatekeeper constraint template |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pkg/validate/fileobjects/raw.go
Outdated
|
|
||
| if gvkutil.Matches(gk, skipGVKErrors) { | ||
| klog.V(6).Infof("ignoring KNV1021 error for %s/%s due to --no-api-server-check-for-group flag: %v", gk.Group, gk.Kind, err) | ||
| continue // Skip appending this error |
Copilot
AI
Nov 6, 2025
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.
The logic skips adding the object to any scope (Cluster, Namespace, or Unknown) when a matching GVK error is encountered. This means these objects are silently dropped from processing. Consider whether the object should still be added to the Unknown scope or if this silent dropping is the intended behavior.
| continue // Skip appending this error | |
| scoped.Unknown = append(scoped.Unknown, obj) | |
| continue // Add to Unknown scope and skip appending this error |
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.
This comment is correct - the object should be retained with Unknown scope rather than skipped
30c3ed3 to
09f4ad2
Compare
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.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| nomos vet --path=my/directory | ||
| nomos vet --path=/path/to/my/directory`, | ||
| Args: cobra.ExactArgs(0), | ||
| PreRunE: func(_ *cobra.Command, _ []string) error { |
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.
Is it possible to just ignore the no-api-server-check-for-group if the no-api-server-check is specified, assuming it's an inclusive action overall
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.
Sounds good. I will also implement a warning message to inform the user that the no-api-server-check-for-group option will be ignored.
52cff8e to
cbd5fff
Compare
|
/retest-required |
pkg/validate/fileobjects/raw.go
Outdated
|
|
||
| if gvkutil.Matches(gk, skipGVKErrors) { | ||
| klog.V(6).Infof("ignoring KNV1021 error for %s/%s due to --no-api-server-check-for-group flag: %v", gk.Group, gk.Kind, err) | ||
| continue // Skip appending this error |
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.
This comment is correct - the object should be retained with Unknown scope rather than skipped
cbd5fff to
818f508
Compare
b0cd6cc to
e61d74d
Compare
|
/retest-required |
042397a to
8cf1e76
Compare
|
/test kpt-config-sync-presubmit |
8cf1e76 to
f84a4d5
Compare
|
/test kpt-config-sync-presubmit |
7c9a2b2 to
b5eacab
Compare
b5eacab to
6fa3a8f
Compare
This commit expands the nomos vet command's capabilities by:
These changes specifically address issue #1633, where nomos vet failed to validate OPA Gatekeeper custom resources when a ConstraintTemplate and its corresponding Constraint were present in the same commit. The improved raw resource processing and flag handling now allow nomos vet to correctly process such configurations, preventing the KNV1021 error.