Skip to content

Commit 3499c8f

Browse files
committed
correctly identify if patch was done in status
1 parent d5bc873 commit 3499c8f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/client/fake/client.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (t versionedTracker) Update(gvr schema.GroupVersionResource, obj runtime.Ob
361361
isStatus := false
362362
// We apply patches using a client-go reaction that ends up calling the trackers Update. As we can't change
363363
// that reaction, we use the callstack to figure out if this originated from the status client.
364-
if bytes.Contains(debug.Stack(), []byte("sigs.k8s.io/controller-runtime/pkg/client/fake.(*fakeSubResourceClient).Patch")) {
364+
if bytes.Contains(debug.Stack(), []byte("sigs.k8s.io/controller-runtime/pkg/client/fake.(*fakeSubResourceClient).statusPatch")) {
365365
isStatus = true
366366
}
367367
return t.update(gvr, obj, ns, isStatus, false)
@@ -1090,6 +1090,15 @@ func (sw *fakeSubResourceClient) Patch(ctx context.Context, obj client.Object, p
10901090
body = patchOptions.SubResourceBody
10911091
}
10921092

1093+
// this is necessary to identify that last call was made for status patch, through stack trace.
1094+
if sw.subResource == "status" {
1095+
return sw.statusPatch(body, patch, patchOptions)
1096+
}
1097+
1098+
return sw.client.patch(body, patch, &patchOptions.PatchOptions)
1099+
}
1100+
1101+
func (sw *fakeSubResourceClient) statusPatch(body client.Object, patch client.Patch, patchOptions client.SubResourcePatchOptions) error {
10931102
return sw.client.patch(body, patch, &patchOptions.PatchOptions)
10941103
}
10951104

0 commit comments

Comments
 (0)