mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Use typedefs for Begin* functions
David asked for this for readability, even if not all other hooks do it.
This commit is contained in:
parent
25da6a0660
commit
37b34f5b53
@ -56,9 +56,15 @@ type FinishFunc func(ctx context.Context, success bool)
|
|||||||
// AfterDeleteFunc is the type used for the Store.AfterDelete hook.
|
// AfterDeleteFunc is the type used for the Store.AfterDelete hook.
|
||||||
type AfterDeleteFunc func(obj runtime.Object, options *metav1.DeleteOptions)
|
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.
|
// AfterCreateFunc is the type used for the Store.AfterCreate hook.
|
||||||
type AfterCreateFunc func(obj runtime.Object, options *metav1.CreateOptions)
|
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.
|
// AfterUpdateFunc is the type used for the Store.AfterUpdate hook.
|
||||||
type AfterUpdateFunc func(obj runtime.Object, options *metav1.UpdateOptions)
|
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
|
// but before AfterCreate and Decorator, indicating via the argument
|
||||||
// whether the operation succeeded. If this returns an error, the function
|
// whether the operation succeeded. If this returns an error, the function
|
||||||
// is not called. Almost nobody should use this hook.
|
// 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
|
// AfterCreate implements a further operation to run after a resource is
|
||||||
// created and before it is decorated, optional.
|
// created and before it is decorated, optional.
|
||||||
AfterCreate AfterCreateFunc
|
AfterCreate AfterCreateFunc
|
||||||
@ -174,7 +180,7 @@ type Store struct {
|
|||||||
// but before AfterUpdate and Decorator, indicating via the argument
|
// but before AfterUpdate and Decorator, indicating via the argument
|
||||||
// whether the operation succeeded. If this returns an error, the function
|
// whether the operation succeeded. If this returns an error, the function
|
||||||
// is not called. Almost nobody should use this hook.
|
// 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
|
// AfterUpdate implements a further operation to run after a resource is
|
||||||
// updated and before it is decorated, optional.
|
// updated and before it is decorated, optional.
|
||||||
AfterUpdate AfterUpdateFunc
|
AfterUpdate AfterUpdateFunc
|
||||||
|
@ -499,7 +499,7 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
decorator func(runtime.Object)
|
decorator func(runtime.Object)
|
||||||
beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
beginCreate BeginCreateFunc
|
||||||
afterCreate AfterCreateFunc
|
afterCreate AfterCreateFunc
|
||||||
// the TTLFunc is an easy hook to force a failure
|
// the TTLFunc is an easy hook to force a failure
|
||||||
ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)
|
ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)
|
||||||
@ -798,9 +798,9 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
decorator func(runtime.Object)
|
decorator func(runtime.Object)
|
||||||
// create-on-update is tested elsewhere, but this proves non-use here
|
// 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
|
afterCreate AfterCreateFunc
|
||||||
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
beginUpdate BeginUpdateFunc
|
||||||
afterUpdate AfterUpdateFunc
|
afterUpdate AfterUpdateFunc
|
||||||
expectError bool
|
expectError bool
|
||||||
expectAnnotation string // to test object mutations
|
expectAnnotation string // to test object mutations
|
||||||
@ -927,9 +927,9 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
decorator func(runtime.Object)
|
decorator func(runtime.Object)
|
||||||
beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
beginCreate BeginCreateFunc
|
||||||
afterCreate AfterCreateFunc
|
afterCreate AfterCreateFunc
|
||||||
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
beginUpdate BeginUpdateFunc
|
||||||
afterUpdate AfterUpdateFunc
|
afterUpdate AfterUpdateFunc
|
||||||
// the TTLFunc is an easy hook to force a failure
|
// the TTLFunc is an easy hook to force a failure
|
||||||
ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)
|
ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)
|
||||||
|
Loading…
Reference in New Issue
Block a user