From 8820df7a771d3956cabd8d36ffef23ecb6d71dbf Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Mon, 11 Jul 2022 20:12:21 +0200 Subject: [PATCH] SSA: improve comment about metadata.uid --- .../cluster/structuredmerge/serversidepathhelper.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper.go b/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper.go index 2bcf0a5e0334..eec196b18231 100644 --- a/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper.go +++ b/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper.go @@ -83,8 +83,13 @@ func NewServerSidePatchHelper(ctx context.Context, original, modified client.Obj filterObject(modifiedUnstructured, helperOptions) // Carry over uid to match the intent to: - // * create (uid==""): Setting no uid ensures an object gets created, not updated. - // * update (uid!=""): Setting an uid ensures an object which has the same uid gets updated. + // * create (uid==""): + // * if object doesn't exist => create + // * if object already exists => update + // * update (uid!=""): + // * if object doesn't exist => fail + // * if object already exists => update + // * This allows us to enforce that an update doesn't create an object which has been deleted. modifiedUnstructured.SetUID("") if originalUnstructured != nil { modifiedUnstructured.SetUID(originalUnstructured.GetUID())