-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Pass ctx to Validate, ValidateUpdate #6163
Pass ctx to Validate, ValidateUpdate #6163
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
@smarterclayton @thockin PTAL |
Assigning to @smarterclayton, feel free to re-assign. |
@smarterclayton actually, now that I look at the function signature, since PrepareForCreate/Update doesn't return anything right now, we won't be able to stop a create/update from proceeding when there's a referential integrity issue (i.e. not authorized for Bob to access Alice's ImageStream). |
Does it make sense to have these methods return a ValidationErrorList? or an error? |
Maybe an error. However, that gets into the question of why wouldn't this then be folded into Validate, where there is just two parts of validation in the strategy - inherent, and referential. |
Having Prepare* return an error seems to just be duplicating Validate* |
I thought you had said you didn't want to do referential integrity checking in the Validate* methods. I'm quite happy to modify Validate and ValidateUpdate to take in the ctx instead. |
Not the core Validate methods - the Strategy validate methods.
|
6bfb01f
to
51bdbe0
Compare
@smarterclayton updated to pass ctx to the Validate* strategy methods |
@@ -19,6 +19,8 @@ package controller | |||
import ( | |||
"fmt" | |||
|
|||
"strconv" |
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.
Nuke the whitespace above this
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.
That's from goimports, but ok
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.
Fixed
After you fix that one line LGTM |
Pass ctx to Validate/ValidateUpdate. This is useful so strategies can access data such as the current user.
51bdbe0
to
d7c5f42
Compare
Goimports isn't smart enough to know that "fmt" and "strconv" are in the same group, it just knows that strconv doesn't belong with the deeply nested types. |
Pass ctx to Validate, ValidateUpdate
Pass ctx to Validate/ValidateUpdate. This is useful so strategies can
access data such as the current user.