Skip to content

Conversation

@saschagrunert
Copy link
Member

  • 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

Follow-up on #162

- 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>
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 28, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 28, 2025
@JoelSpeed
Copy link
Contributor

/assign @everettraven

@saschagrunert saschagrunert changed the title WIP: arrayofstruct: follow-up on review arrayofstruct: follow-up on review Oct 28, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 28, 2025
}

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)
Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

@saschagrunert saschagrunert Oct 29, 2025

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. 👍

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 29, 2025
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@saschagrunert saschagrunert force-pushed the arrayofstruct-followup branch from 2993091 to 527590e Compare October 29, 2025 08:05
@JoelSpeed
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2025
Copy link
Contributor

@everettraven everettraven left a 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

Comment on lines +437 to 442
// 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) ||
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants