Commit 73314a04 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #39829 from MHBauer/prepareforcreate-doc

Automatic merge from submit-queue documentation for implementors of RESTCreateStrategy **What this PR does / why we need it**: Documentation useful for those implementing these methods. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: no issue. **Special notes for your reviewer**: I am implementing these for service broker, and gives me examples of what is done or should be done. **Release note**: --> ```release-note NONE ```
parents 6b14216a 1033c976
...@@ -44,6 +44,11 @@ type RESTCreateStrategy interface { ...@@ -44,6 +44,11 @@ type RESTCreateStrategy interface {
// the object. For example: remove fields that are not to be persisted, // the object. For example: remove fields that are not to be persisted,
// sort order-insensitive list fields, etc. This should not remove fields // sort order-insensitive list fields, etc. This should not remove fields
// whose presence would be considered a validation error. // whose presence would be considered a validation error.
//
// Often implemented as a type check and an initailization or clearing of
// status. Clear the status because status changes are internal. External
// callers of an api (users) should not be setting an initial status on
// newly created objects.
PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object)
// Validate returns an ErrorList with validation errors or nil. Validate // Validate returns an ErrorList with validation errors or nil. Validate
// is invoked after default fields in the object have been filled in // is invoked after default fields in the object have been filled in
...@@ -54,7 +59,8 @@ type RESTCreateStrategy interface { ...@@ -54,7 +59,8 @@ type RESTCreateStrategy interface {
// ensures that code that operates on these objects can rely on the common // ensures that code that operates on these objects can rely on the common
// form for things like comparison. Canonicalize is invoked after // form for things like comparison. Canonicalize is invoked after
// validation has succeeded but before the object has been persisted. // validation has succeeded but before the object has been persisted.
// This method may mutate the object. // This method may mutate the object. Often implemented as a type check or
// empty method.
Canonicalize(obj runtime.Object) Canonicalize(obj runtime.Object)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment