Unverified Commit 9e72003b authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #63349 from smarterclayton/decorator

Automatic merge from submit-queue (batch tested with PRs 63349, 63294). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Decorator for Create should be called on out, not obj
parents dbde7ef2 1002f805
......@@ -373,7 +373,7 @@ func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation
}
}
if e.Decorator != nil {
if err := e.Decorator(obj); err != nil {
if err := e.Decorator(out); err != nil {
return nil, err
}
}
......
......@@ -311,6 +311,11 @@ func TestStoreCreate(t *testing.T) {
// re-define delete strategy to have graceful delete capability
defaultDeleteStrategy := testRESTStrategy{scheme, names.SimpleNameGenerator, true, false, true}
registry.DeleteStrategy = testGracefulStrategy{defaultDeleteStrategy}
registry.Decorator = func(obj runtime.Object) error {
pod := obj.(*example.Pod)
pod.Status.Phase = example.PodPhase("Testing")
return nil
}
// create the object with denying admission
objA, err := registry.Create(testContext, podA, denyCreateValidation, false)
......@@ -324,6 +329,11 @@ func TestStoreCreate(t *testing.T) {
t.Errorf("Unexpected error: %v", err)
}
// verify the decorator was called
if objA.(*example.Pod).Status.Phase != example.PodPhase("Testing") {
t.Errorf("Decorator was not called: %#v", objA)
}
// get the object
checkobj, err := registry.Get(testContext, podA.Name, &metav1.GetOptions{})
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment