mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Make REST After* funcs not return error
This commit is contained in:
parent
67c9761623
commit
64491be328
@ -160,7 +160,7 @@ type Store struct {
|
|||||||
BeginCreate func(ctx context.Context, obj runtime.Object, options *metav1.CreateOptions) (FinishFunc, error)
|
BeginCreate func(ctx context.Context, obj runtime.Object, options *metav1.CreateOptions) (FinishFunc, error)
|
||||||
// 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 ObjectFunc
|
AfterCreate func(runtime.Object)
|
||||||
|
|
||||||
// UpdateStrategy implements resource-specific behavior during updates.
|
// UpdateStrategy implements resource-specific behavior during updates.
|
||||||
UpdateStrategy rest.RESTUpdateStrategy
|
UpdateStrategy rest.RESTUpdateStrategy
|
||||||
@ -172,13 +172,13 @@ type Store struct {
|
|||||||
BeginUpdate func(ctx context.Context, obj, old runtime.Object, options *metav1.UpdateOptions) (FinishFunc, error)
|
BeginUpdate func(ctx context.Context, obj, old runtime.Object, options *metav1.UpdateOptions) (FinishFunc, error)
|
||||||
// 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 ObjectFunc
|
AfterUpdate func(runtime.Object)
|
||||||
|
|
||||||
// DeleteStrategy implements resource-specific behavior during deletion.
|
// DeleteStrategy implements resource-specific behavior during deletion.
|
||||||
DeleteStrategy rest.RESTDeleteStrategy
|
DeleteStrategy rest.RESTDeleteStrategy
|
||||||
// AfterDelete implements a further operation to run after a resource is
|
// AfterDelete implements a further operation to run after a resource is
|
||||||
// deleted and before it is decorated, optional.
|
// deleted and before it is decorated, optional.
|
||||||
AfterDelete ObjectFunc
|
AfterDelete func(runtime.Object)
|
||||||
// ReturnDeletedObject determines whether the Store returns the object
|
// ReturnDeletedObject determines whether the Store returns the object
|
||||||
// that was deleted. Otherwise, return a generic success status response.
|
// that was deleted. Otherwise, return a generic success status response.
|
||||||
ReturnDeletedObject bool
|
ReturnDeletedObject bool
|
||||||
@ -422,9 +422,7 @@ func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation
|
|||||||
fn(ctx, true)
|
fn(ctx, true)
|
||||||
|
|
||||||
if e.AfterCreate != nil {
|
if e.AfterCreate != nil {
|
||||||
if err := e.AfterCreate(out); err != nil {
|
e.AfterCreate(out)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if e.Decorator != nil {
|
if e.Decorator != nil {
|
||||||
if err := e.Decorator(out); err != nil {
|
if err := e.Decorator(out); err != nil {
|
||||||
@ -666,15 +664,11 @@ func (e *Store) Update(ctx context.Context, name string, objInfo rest.UpdatedObj
|
|||||||
|
|
||||||
if creating {
|
if creating {
|
||||||
if e.AfterCreate != nil {
|
if e.AfterCreate != nil {
|
||||||
if err := e.AfterCreate(out); err != nil {
|
e.AfterCreate(out)
|
||||||
return nil, false, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if e.AfterUpdate != nil {
|
if e.AfterUpdate != nil {
|
||||||
if err := e.AfterUpdate(out); err != nil {
|
e.AfterUpdate(out)
|
||||||
return nil, false, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if e.Decorator != nil {
|
if e.Decorator != nil {
|
||||||
@ -1165,9 +1159,7 @@ func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.Vali
|
|||||||
// returns the decorated deleted object if appropriate.
|
// returns the decorated deleted object if appropriate.
|
||||||
func (e *Store) finalizeDelete(ctx context.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) {
|
func (e *Store) finalizeDelete(ctx context.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) {
|
||||||
if runHooks && e.AfterDelete != nil {
|
if runHooks && e.AfterDelete != nil {
|
||||||
if err := e.AfterDelete(obj); err != nil {
|
e.AfterDelete(obj)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if e.ReturnDeletedObject {
|
if e.ReturnDeletedObject {
|
||||||
if e.Decorator != nil {
|
if e.Decorator != nil {
|
||||||
|
@ -440,7 +440,7 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
decorator ObjectFunc
|
decorator ObjectFunc
|
||||||
beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
||||||
afterCreate ObjectFunc
|
afterCreate func(runtime.Object)
|
||||||
// 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)
|
||||||
expectError bool
|
expectError bool
|
||||||
@ -457,9 +457,8 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
expectAnnotation: "DecoratorWasCalled",
|
expectAnnotation: "DecoratorWasCalled",
|
||||||
}, {
|
}, {
|
||||||
name: "AfterCreate mutation",
|
name: "AfterCreate mutation",
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
setAnn(obj, "AfterCreateWasCalled")
|
setAnn(obj, "AfterCreateWasCalled")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
expectAnnotation: "AfterCreateWasCalled",
|
expectAnnotation: "AfterCreateWasCalled",
|
||||||
}, {
|
}, {
|
||||||
@ -475,9 +474,8 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -492,9 +490,8 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -515,9 +512,8 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return fmt.Errorf("decorator")
|
return fmt.Errorf("decorator")
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -526,24 +522,6 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
expectMilestones: []string{"BeginCreate", "FinishCreate(true)", "AfterCreate", "Decorator"},
|
expectMilestones: []string{"BeginCreate", "FinishCreate(true)", "AfterCreate", "Decorator"},
|
||||||
}, {
|
|
||||||
name: "fail AfterCreate ordering",
|
|
||||||
expectError: true,
|
|
||||||
decorator: func(obj runtime.Object) error {
|
|
||||||
mile("Decorator")
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
afterCreate: func(obj runtime.Object) error {
|
|
||||||
mile("AfterCreate")
|
|
||||||
return fmt.Errorf("after")
|
|
||||||
},
|
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
|
||||||
mile("BeginCreate")
|
|
||||||
return func(_ context.Context, success bool) {
|
|
||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
expectMilestones: []string{"BeginCreate", "FinishCreate(true)", "AfterCreate"},
|
|
||||||
}, {
|
}, {
|
||||||
name: "fail BeginCreate ordering",
|
name: "fail BeginCreate ordering",
|
||||||
expectError: true,
|
expectError: true,
|
||||||
@ -551,9 +529,8 @@ func TestStoreCreateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -783,9 +760,9 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
decorator ObjectFunc
|
decorator ObjectFunc
|
||||||
// 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 func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
||||||
afterCreate ObjectFunc
|
afterCreate func(runtime.Object)
|
||||||
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
||||||
afterUpdate ObjectFunc
|
afterUpdate func(runtime.Object)
|
||||||
expectError bool
|
expectError bool
|
||||||
expectAnnotation string // to test object mutations
|
expectAnnotation string // to test object mutations
|
||||||
expectMilestones []string // to test sequence
|
expectMilestones []string // to test sequence
|
||||||
@ -800,9 +777,8 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
expectAnnotation: "DecoratorWasCalled",
|
expectAnnotation: "DecoratorWasCalled",
|
||||||
}, {
|
}, {
|
||||||
name: "AfterUpdate mutation",
|
name: "AfterUpdate mutation",
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
setAnn(obj, "AfterUpdateWasCalled")
|
setAnn(obj, "AfterUpdateWasCalled")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
expectAnnotation: "AfterUpdateWasCalled",
|
expectAnnotation: "AfterUpdateWasCalled",
|
||||||
}, {
|
}, {
|
||||||
@ -818,9 +794,8 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -828,9 +803,8 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -846,9 +820,8 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return fmt.Errorf("decorator")
|
return fmt.Errorf("decorator")
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -857,24 +830,6 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
expectMilestones: []string{"BeginUpdate", "FinishUpdate(true)", "AfterUpdate", "Decorator"},
|
expectMilestones: []string{"BeginUpdate", "FinishUpdate(true)", "AfterUpdate", "Decorator"},
|
||||||
}, {
|
|
||||||
name: "fail AfterUpdate ordering",
|
|
||||||
expectError: true,
|
|
||||||
decorator: func(obj runtime.Object) error {
|
|
||||||
mile("Decorator")
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
|
||||||
mile("AfterUpdate")
|
|
||||||
return fmt.Errorf("after")
|
|
||||||
},
|
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
|
||||||
mile("BeginUpdate")
|
|
||||||
return func(_ context.Context, success bool) {
|
|
||||||
mile(fmt.Sprintf("FinishUpdate(%v)", success))
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
expectMilestones: []string{"BeginUpdate", "FinishUpdate(true)", "AfterUpdate"},
|
|
||||||
}, {
|
}, {
|
||||||
name: "fail BeginUpdate ordering",
|
name: "fail BeginUpdate ordering",
|
||||||
expectError: true,
|
expectError: true,
|
||||||
@ -882,9 +837,8 @@ func TestStoreUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -955,9 +909,9 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
decorator ObjectFunc
|
decorator ObjectFunc
|
||||||
beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
beginCreate func(context.Context, runtime.Object, *metav1.CreateOptions) (FinishFunc, error)
|
||||||
afterCreate ObjectFunc
|
afterCreate func(runtime.Object)
|
||||||
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
||||||
afterUpdate ObjectFunc
|
afterUpdate func(runtime.Object)
|
||||||
// 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)
|
||||||
expectError bool
|
expectError bool
|
||||||
@ -970,9 +924,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -980,9 +933,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -997,9 +949,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -1007,9 +958,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -1030,9 +980,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return fmt.Errorf("decorator")
|
return fmt.Errorf("decorator")
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -1040,9 +989,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -1051,34 +999,6 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
expectMilestones: []string{"BeginCreate", "FinishCreate(true)", "AfterCreate", "Decorator"},
|
expectMilestones: []string{"BeginCreate", "FinishCreate(true)", "AfterCreate", "Decorator"},
|
||||||
}, {
|
|
||||||
name: "fail AfterCreate ordering",
|
|
||||||
expectError: true,
|
|
||||||
decorator: func(obj runtime.Object) error {
|
|
||||||
mile("Decorator")
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
afterCreate: func(obj runtime.Object) error {
|
|
||||||
mile("AfterCreate")
|
|
||||||
return fmt.Errorf("after")
|
|
||||||
},
|
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
|
||||||
mile("BeginCreate")
|
|
||||||
return func(_ context.Context, success bool) {
|
|
||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
|
||||||
mile("AfterUpdate")
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
|
||||||
mile("BeginUpdate")
|
|
||||||
return func(_ context.Context, success bool) {
|
|
||||||
mile(fmt.Sprintf("FinishUpdate(%v)", success))
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
expectMilestones: []string{"BeginCreate", "FinishCreate(true)", "AfterCreate"},
|
|
||||||
}, {
|
}, {
|
||||||
name: "fail BeginCreate ordering",
|
name: "fail BeginCreate ordering",
|
||||||
expectError: true,
|
expectError: true,
|
||||||
@ -1086,9 +1006,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterCreate: func(obj runtime.Object) error {
|
afterCreate: func(obj runtime.Object) {
|
||||||
mile("AfterCreate")
|
mile("AfterCreate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
beginCreate: func(_ context.Context, obj runtime.Object, _ *metav1.CreateOptions) (FinishFunc, error) {
|
||||||
mile("BeginCreate")
|
mile("BeginCreate")
|
||||||
@ -1096,9 +1015,8 @@ func TestStoreCreateOnUpdateHooks(t *testing.T) {
|
|||||||
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
mile(fmt.Sprintf("FinishCreate(%v)", success))
|
||||||
}, fmt.Errorf("begin")
|
}, fmt.Errorf("begin")
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -1174,7 +1092,7 @@ func TestStoreUpdateHooksInnerRetry(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
decorator func(runtime.Object) error
|
decorator func(runtime.Object) error
|
||||||
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
beginUpdate func(context.Context, runtime.Object, runtime.Object, *metav1.UpdateOptions) (FinishFunc, error)
|
||||||
afterUpdate func(runtime.Object) error
|
afterUpdate func(runtime.Object)
|
||||||
// the TTLFunc is an easy hook to force an inner-loop retry
|
// the TTLFunc is an easy hook to force an inner-loop retry
|
||||||
ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)
|
ttl func(obj runtime.Object, existing uint64, update bool) (uint64, error)
|
||||||
expectError bool
|
expectError bool
|
||||||
@ -1185,9 +1103,8 @@ func TestStoreUpdateHooksInnerRetry(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
@ -1203,9 +1120,8 @@ func TestStoreUpdateHooksInnerRetry(t *testing.T) {
|
|||||||
mile("Decorator")
|
mile("Decorator")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
afterUpdate: func(obj runtime.Object) error {
|
afterUpdate: func(obj runtime.Object) {
|
||||||
mile("AfterUpdate")
|
mile("AfterUpdate")
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
beginUpdate: func(_ context.Context, obj, _ runtime.Object, _ *metav1.UpdateOptions) (FinishFunc, error) {
|
||||||
mile("BeginUpdate")
|
mile("BeginUpdate")
|
||||||
|
Loading…
Reference in New Issue
Block a user