-
Notifications
You must be signed in to change notification settings - Fork 25
feat: support ExactlyOneOf marker in arrayofstruct analyzer #181
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?
Changes from 1 commit
df6a56e
7b1857d
00be0af
cb9eec6
a543674
eb4f5fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,3 +150,15 @@ type ValidStructWithCustomBasicType struct { | |
| // This should not trigger the linter because CustomString is based on string, a basic type | ||
| Items []CustomString | ||
| } | ||
|
|
||
| // Valid case - struct with ExactlyOneOf marker | ||
| type ValidWithExactlyOneOf struct { | ||
| Items []ValidExactlyOneOfItem | ||
| } | ||
|
|
||
| type ValidExactlyOneOfItem struct { | ||
| // +kubebuilder:validation:ExactlyOneOf=FieldA;FieldB | ||
|
||
| // No required fields, but the marker enforces exactly one is set | ||
| FieldA *string `json:"fieldA,omitempty"` | ||
| FieldB *string `json:"fieldB,omitempty"` | ||
| } | ||
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.
Reading the description of this marker on https://book.kubebuilder.io/reference/markers/crd-validation it looks like this is only on the type definition and not the individual fields.
You should be able to get the set of markers on a struct using
kube-api-linter/pkg/analysis/helpers/markers/analyzer.go
Line 81 in 5fca1e8
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.
Updated to use StructMarkers() and Marker is on struct definition