-
Notifications
You must be signed in to change notification settings - Fork 629
🌱 enable requiredfields linter #5643
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?
Conversation
[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 |
Hi @v47. Thanks for your PR. I'm waiting for a kubernetes-sigs 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-sigs/prow repository. |
/ok-to-test |
Please update KAL to the latest version. After discussion with the Kube API reviewers, and updates to the Kube API conventions, the required fields rule has been rewritten and will now recommend |
/hold |
Also the PR needs a retitle. |
…ditions checks in .golangci-kal.yml (comment out conditions config). The older version was not picking them.
2f48458
to
43a07db
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.
In a lot of cases, changing the serialization can be breaking, though clients do need to update to the new library version for this to take effect.
Where we already have a non-zero min length, adding omitempty
/omitzero
should be safe, since no one should have persisted an empty value anyway
Where there aren't min lengths already, this could be problematic. Have you checked what the behaviour is when a zero value is persisted and you upgrade into this schema/client?
Existing values should be fine because of ratcheting validation, but, if the client now starts omitting the value, it will remove the value on write and this will lead to a required validation coming up, which would then be breaking
// This is also known as audience. The ID for the client application that makes | ||
// authentication requests to the OpenID identity provider. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MinLength=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.
Have you verified that this ratchets?
// | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:Pattern=`^https://.+` |
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.
Might be better to use a CEL validation if possible, isURL
likely more comprehensive
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.
Did you have something like this in mind?
// +kubebuilder:validation:XValidation:rule="isURL(self) && url(self).getScheme() == 'https'"
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.
Exactly, and then you can add ,message="..."
with a custom error message too
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.
@JoelSpeed, the validation for https was addressed.
9781f5b
to
99178e8
Compare
/retest |
2 similar comments
/retest |
/retest |
// AWSLaunchTemplate specifies the launch template and version to use when an instance is launched. | ||
// +kubebuilder:validation:Required | ||
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"` | ||
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate,omitzero"` |
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 doing this causes an issue in the tests because it omits the zero value for this which is required by the validation checks:
AWSMachinePool.infrastructure.cluster.x-k8s.io "test" is invalid: spec.awsLaunchTemplate: Required value
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.
yup, saw it, but now for me it's a question, how required AWSLaunchTemplate should be treated?
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.
@damdo @JoelSpeed sorry, do you have an opinion about the changes related to AWSMachinePool?
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.
How did you fix it? Did you run generation again?
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.
https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/5643/files#diff-870af3af95309601f80ec2a719be848510d92c57065a88a5f465ac646259db55R101
i added AWSLaunchTemplate in the tests.
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.
Ok thanks, let's see what @JoelSpeed thinks of the overall changes
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 linter is basically saying that you should require a non-zero AWSMachineTemplate. Does the AWSMachineTemplate have any required fields presently? Or can I today commit {}
to the API and that be valid?
11bc858
to
216ebdd
Compare
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes :
Fixes #5492
Checklist:
Release note: