-
Notifications
You must be signed in to change notification settings - Fork 264
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
Use ReadUIntFromLabel to validate index label. #3666
base: main
Are you sure you want to change the base?
Use ReadUIntFromLabel to validate index label. #3666
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mbobrovskyi 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 |
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
42788fd
to
6771c79
Compare
6771c79
to
54603af
Compare
54603af
to
cc8348b
Compare
1141ea5
to
463b739
Compare
463b739
to
0dbfee9
Compare
/cc @mimowo |
pkg/util/pod/pod.go
Outdated
func readUIntFromStringWithMax(value string, max int) (*int, error) { | ||
uintValue, err := strconv.ParseUint(value, 10, 0) | ||
if err != nil { | ||
return nil, err |
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.
Hm, maybe we could re-package the error into errInvalidInt
so that it is easier to assert?
IIUC this could work: return nil, fmt.Sprintf("%w, message: %v", errInvalidInt, err.Error())
, then we could assert on errInvalidInt
rather than strings.
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.
cc @PBundyra as it may impact also your approach to testing
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.
Done
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.
Can you check if return nil, fmt.Sprintf("%w, message: %s", errInvalidInt, err.Error())
works? I think it might be useful to get contextual information.
7a662a2
to
6c4aeb0
Compare
6c4aeb0
to
b20d2e2
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.
Overall lgtm, proposing some improvements to usability of the new functions
ceda57f
to
6c30cf2
Compare
6c30cf2
to
1680a2a
Compare
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Use ReadUIntFromLabel to validate index label.
Which issue(s) this PR fixes:
Fixes #3651
Special notes for your reviewer:
Does this PR introduce a user-facing change?