documentation for implementors of RESTCreateStrategy

This commit is contained in:
Morgan Bauer 2017-01-12 13:55:48 -08:00
parent 0f3403d351
commit 1033c976f0
No known key found for this signature in database
GPG Key ID: 7D6FCBD87CAC0C42

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)
}