mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user