Pass ctx to Validate, ValidateUpdate

Pass ctx to Validate/ValidateUpdate. This is useful so strategies can
access data such as the current user.
This commit is contained in:
Andy Goldstein
2015-03-30 13:51:33 -04:00
parent d5ce931f0b
commit d7c5f427cb
10 changed files with 25 additions and 25 deletions

View File

@@ -39,7 +39,7 @@ type RESTUpdateStrategy interface {
PrepareForUpdate(obj, old runtime.Object)
// ValidateUpdate is invoked after default fields in the object have been filled in before
// the object is persisted.
ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList
ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList
}
// BeforeUpdate ensures that common operations for all resources are performed on update. It only returns
@@ -58,7 +58,7 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx api.Context, obj, old runtime
objectMeta.Namespace = api.NamespaceNone
}
strategy.PrepareForUpdate(obj, old)
if errs := strategy.ValidateUpdate(obj, old); len(errs) > 0 {
if errs := strategy.ValidateUpdate(ctx, obj, old); len(errs) > 0 {
return errors.NewInvalid(kind, objectMeta.Name, errs)
}
return nil