From 0edb970c1769283d06e458e9db7ce946f7e70d8c Mon Sep 17 00:00:00 2001 From: Frank Yang Date: Thu, 18 Nov 2021 22:00:54 +0800 Subject: [PATCH] feat(sample-controller): use update status Signed-off-by: Frank Yang Kubernetes-commit: 01e9c80d90c5a6da8278d0785ef583e01f901c1e --- controller.go | 2 +- controller_test.go | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/controller.go b/controller.go index 82611e95..439fafa5 100644 --- a/controller.go +++ b/controller.go @@ -328,7 +328,7 @@ func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1 // we must use Update instead of UpdateStatus to update the Status block of the Foo resource. // UpdateStatus will not allow changes to the Spec of the resource, // which is ideal for ensuring nothing other than resource status has been updated. - _, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).Update(context.TODO(), fooCopy, metav1.UpdateOptions{}) + _, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).UpdateStatus(context.TODO(), fooCopy, metav1.UpdateOptions{}) return err } diff --git a/controller_test.go b/controller_test.go index c6f103da..75741a72 100644 --- a/controller_test.go +++ b/controller_test.go @@ -236,9 +236,7 @@ func (f *fixture) expectUpdateDeploymentAction(d *apps.Deployment) { } func (f *fixture) expectUpdateFooStatusAction(foo *samplecontroller.Foo) { - action := core.NewUpdateAction(schema.GroupVersionResource{Resource: "foos"}, foo.Namespace, foo) - // TODO: Until #38113 is merged, we can't use Subresource - //action.Subresource = "status" + action := core.NewUpdateSubresourceAction(schema.GroupVersionResource{Resource: "foos"}, "status", foo.Namespace, foo) f.actions = append(f.actions, action) }