From a608276987a90c09c9f624d4a1e74b0634f56a12 Mon Sep 17 00:00:00 2001 From: Andres Martinez Gotor Date: Mon, 19 May 2025 11:25:28 +0200 Subject: [PATCH] fix patch --- apps/advisor/pkg/app/utils.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/advisor/pkg/app/utils.go b/apps/advisor/pkg/app/utils.go index 600ff36f359..985c3437775 100644 --- a/apps/advisor/pkg/app/utils.go +++ b/apps/advisor/pkg/app/utils.go @@ -75,23 +75,25 @@ func processCheck(ctx context.Context, log logging.Logger, client resource.Clien } c.Status.Report = *report c.SetAnnotations(obj.GetAnnotations()) - // This works, the updated object contains the new status - updated, err := client.Update(ctx, obj.GetStaticMetadata().Identifier(), c, resource.UpdateOptions{ + // // This works, the updated object contains the new status + // updated, err := client.Update(ctx, obj.GetStaticMetadata().Identifier(), c, resource.UpdateOptions{ + // Subresource: "status", + // }) + // if err != nil { + // return err + // } + // log.Info("updated", "updated", updated) + // This also works now, need to use "status" subresource + patched, err := client.Patch(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{ + Operations: []resource.PatchOperation{{ + Operation: resource.PatchOpAdd, + Path: "/status", + Value: c.Status, + }}, + }, resource.PatchOptions{ Subresource: "status", }) - if err != nil { - return err - } - log.Info("updated", "updated", updated) - // This doesn't work, the patched object contains the old status - // patched, err := client.Patch(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{ - // Operations: []resource.PatchOperation{{ - // Operation: resource.PatchOpAdd, - // Path: "/status", - // Value: c.Status, - // }}, - // }, resource.PatchOptions{}) - // log.Info("patched", "patched", patched) + log.Info("patched", "patched", patched) return err }