diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go index 65d0cba81b0..4a80a43948d 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go @@ -56,9 +56,15 @@ type FinishFunc func(ctx context.Context, success bool) // AfterDeleteFunc is the type used for the Store.AfterDelete hook. type AfterDeleteFunc func(obj runtime.Object, options *metav1.DeleteOptions) +// BeginCreateFunc is the type used for the Store.BeginCreate hook. +type BeginCreateFunc func(ctx context.Context, obj runtime.Object, options *metav1.CreateOptions) (FinishFunc, error) + // AfterCreateFunc is the type used for the Store.AfterCreate hook. type AfterCreateFunc func(obj runtime.Object, options *metav1.CreateOptions) +// BeginUpdateFunc is the type used for the Store.BeginUpdate hook. +type BeginUpdateFunc func(ctx context.Context, obj, old runtime.Object, options *metav1.UpdateOptions) (FinishFunc, error) + // AfterUpdateFunc is the type used for the Store.AfterUpdate hook. type AfterUpdateFunc func(obj runtime.Object, options *metav1.UpdateOptions) @@ -162,7 +168,7 @@ type Store struct { // but before AfterCreate and Decorator, indicating via the argument // whether the operation succeeded. If this returns an error, the function // is not called. Almost nobody should use this hook. - BeginCreate func(ctx context.Context, obj runtime.Object, options *metav1.CreateOptions) (FinishFunc, error) + BeginCreate BeginCreateFunc // AfterCreate implements a further operation to run after a resource is // created and before it is decorated, optional. AfterCreate AfterCreateFunc @@ -174,7 +180,7 @@ type Store struct { // but before AfterUpdate and Decorator, indicating via the argument // whether the operation succeeded. If this returns an error, the function // is not called. Almost nobody should use this hook. - BeginUpdate func(ctx context.Context, obj, old runtime.Object, options *metav1.UpdateOptions) (FinishFunc, error) + BeginUpdate BeginUpdateFunc // AfterUpdate implements a further operation to run after a resource is // updated and before it is decorated, optional. AfterUpdate AfterUpdateFunc diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go index 58f016b465f..3f89a3fac82 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go @@ -499,7 +499,7 @@ func TestStoreCreateHooks(t *testing.T) { testCases := []struct { name string decorator func(runtime.Object) - beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error) + beginCreate BeginCreateFunc afterCreate AfterCreateFunc // the TTLFunc is an easy hook to force a failure ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error) @@ -798,9 +798,9 @@ func TestStoreUpdateHooks(t *testing.T) { name string decorator func(runtime.Object) // create-on-update is tested elsewhere, but this proves non-use here - beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error) + beginCreate BeginCreateFunc afterCreate AfterCreateFunc - beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error) + beginUpdate BeginUpdateFunc afterUpdate AfterUpdateFunc expectError bool expectAnnotation string // to test object mutations @@ -927,9 +927,9 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) { testCases := []struct { name string decorator func(runtime.Object) - beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error) + beginCreate BeginCreateFunc afterCreate AfterCreateFunc - beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error) + beginUpdate BeginUpdateFunc afterUpdate AfterUpdateFunc // the TTLFunc is an easy hook to force a failure ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)