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
Separate validation concern from rest of RESTStorage #2977
Comments
@smarterclayton @lavalamp @liggitt - this is related to the topic we discussed at meet-up on simplifying the |
You used the four letter b-word
|
@smarterclayton - github update comment let's me fix my mistake ;-) |
"Boilerplate" has far more than four letters :) |
Yes, the apiserver and RESTStorage implementations should be generic. |
This is now possible, when people switch to genericetcd they must implement a strategy (which hides this) |
Closing this issue because I agree it's now possible. Thanks @smarterclayton |
KEP: Create a `k8s.io/component` repo
The majority of unique code per resource type in our
RESTStorage
implementations deals with populating default values on an object and validating the object prior to persistence. The other 99% of the code is pretty common across all of our resource types and could be generalized. When we look at our tests, the majority of ourrest_test.go
files are just ensuring that validation occurs prior to create/update. There is a lot of duplicate effort where we could just mandate that the framework that calls theRESTStorage
guarantees that the object is valid.I would like to suggest that the
resthandler.go
logic enforces that prior to calling aRESTStorage
Create and Update operation, it makes a call to something like the following:In addition, as we look to the future, there are some additional concepts that I would like the
resthandler.go
to enforce uniformly across all resources without adding more boilerplate into eachRESTStorage
implementation. Specifically, I do not want to invoke any Admission control style logic for invalid input, but I do not want to modify eachRESTStorage
implementation to have to make an explicit call-out to perform admission control as it just increases more boiler plate code.The text was updated successfully, but these errors were encountered: