-
Notifications
You must be signed in to change notification settings - Fork 919
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
work suspension: webhook validation #5282
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5282 +/- ##
==========================================
+ Coverage 28.38% 28.40% +0.02%
==========================================
Files 632 632
Lines 43801 43810 +9
==========================================
+ Hits 12432 12444 +12
+ Misses 30464 30462 -2
+ Partials 905 904 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/hold until #4838 is merged |
/assign |
Hi @a7i we can continue this task ^-^ |
bda6298
to
8e4c70c
Compare
/remove-hold |
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.
/assign
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.
Generally looks good.
I'm surprised that this PR is not based on the latest commit, but all tests are passing. I fetched the PR on my side (by git fetch upstream pull/5282/head:5282
) and it failed to compile as missing the API definition.
I'm unsure if this is due to GitHub Action changing how it fetches code.
Anyway, @a7i could you please help to rebase this and push again?
pkg/util/validation/validation.go
Outdated
if !ptr.Deref(suspension.Dispatching, false) { | ||
return nil | ||
} | ||
|
||
if suspension.DispatchingOnClusters == nil || len(suspension.DispatchingOnClusters.ClusterNames) == 0 { | ||
return nil | ||
} | ||
|
||
return field.ErrorList{ | ||
field.Invalid(fldPath.Child("suspension"), suspension, "suspension dispatching cannot co-exist with dispatchingOnClusters.clusterNames"), | ||
} |
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 would prefer this straightforward style:
if !ptr.Deref(suspension.Dispatching, false) { | |
return nil | |
} | |
if suspension.DispatchingOnClusters == nil || len(suspension.DispatchingOnClusters.ClusterNames) == 0 { | |
return nil | |
} | |
return field.ErrorList{ | |
field.Invalid(fldPath.Child("suspension"), suspension, "suspension dispatching cannot co-exist with dispatchingOnClusters.clusterNames"), | |
} | |
if (suspension.Dispatching != nil && *suspension.Dispatching == true) && | |
(suspension.DispatchingOnClusters != nil && len(suspension.DispatchingOnClusters.ClusterNames) > 0) { | |
return field.ErrorList{ | |
field.Invalid(fldPath.Child("suspension"), suspension, "suspension dispatching cannot co-exist with dispatchingOnClusters.clusterNames"), | |
} | |
} | |
return nil |
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 old version was easier to digest for me ... ideally 1 comment per if
explaining what is going on
suggested feels a overwhelming
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'm sorry for not explaining why I'm suggesting that in detail.
Firstly the old version is great, it looks simple. But given that we need a single check on whether the two fields co-exist, I tend to a more cohesive approach to make it easier to add more checks in the future.
8e4c70c
to
1e0e0a6
Compare
thanks for the review @RainbowMango rebased and applied the suggestion |
Signed-off-by: Amir Alavi <[email protected]>
1e0e0a6
to
d9e174b
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango 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 |
/retest |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #5118
Special notes for your reviewer:
Does this PR introduce a user-facing change?: