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
```
This commit is contained in:
Kubernetes Submit Queue 2017-05-26 00:47:36 -07:00 committed by GitHub
commit 73314a04e4

View File

@ -44,6 +44,11 @@ type RESTCreateStrategy interface {
// the object. For example: remove fields that are not to be persisted,
// sort order-insensitive list fields, etc. This should not remove fields
// 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)
// Validate returns an ErrorList with validation errors or nil. Validate
// is invoked after default fields in the object have been filled in
@ -54,7 +59,8 @@ type RESTCreateStrategy interface {
// ensures that code that operates on these objects can rely on the common
// form for things like comparison. Canonicalize is invoked after
// 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)
}