-
Notifications
You must be signed in to change notification settings - Fork 21
arrayofstruct: follow-up on review #166
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?
arrayofstruct: follow-up on review #166
Conversation
- Exported IsFieldRequired utility function - Updated hasRequiredField to use the exported utility - Added recursion exit condition for basic types - Updated error message to avoid specifying exact marker Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
|
/assign @everettraven |
| } | ||
|
|
||
| message := fmt.Sprintf("%s is an array of structs, but the struct has no required fields. At least one field should be marked as %s to prevent ambiguous YAML configurations", prefix, markers.RequiredMarker) | ||
| message := fmt.Sprintf("%s is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations", prefix) |
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.
Do we need test updates with this change? I'd suspect we do.
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.
+1
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.
Added two new test cases for that change in 2993091
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 don't think this change is enough because I can't see this message as want in test-cases yet. You just added valid case, but we also want invalid case of this message.
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.
Yeah we can probably re-use the existing cases and extend them with the error message. 👍
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2993091 to
527590e
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described 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.
Other than noticing a potential need for a rebase, this LGTM
| // IsFieldRequired checks if the field is required. | ||
| // It checks for the presence of the required marker, the kubebuilder required marker, or the k8s required marker. | ||
| func isFieldRequired(field *ast.Field, markersAccess markershelper.Markers) bool { | ||
| func IsFieldRequired(field *ast.Field, markersAccess markershelper.Markers) bool { | ||
| fieldMarkers := markersAccess.FieldMarkers(field) | ||
|
|
||
| return fieldMarkers.Has(markers.RequiredMarker) || |
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 think I saw this change get merged recently as part of another change. You may need to rebase to pick this up.
Follow-up on #162