Skip to content

Commit 3e3707d

Browse files
committed
Adopt controller-runtime change PR3229: fake client cleared apiversion/kind
Signed-off-by: RainbowMango <[email protected]>
1 parent e27887b commit 3e3707d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/controllers/execution/execution_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,14 @@ func (c *Controller) updateWorkDispatchingConditionIfNeeded(ctx context.Context,
358358
return err
359359
}
360360

361+
// This is a workaround to fix the unit test that the group version kind is not set in the work object when using fake client.
362+
// Without the apiversion and kind, the event will be ignored as missing mandatory object reference.
363+
// Since controller-runtime v0.22.0, the group version kind is not set when using fake client.
364+
// See https://github.com/kubernetes-sigs/controller-runtime/pull/3229 for more details.
365+
if work.GetObjectKind().GroupVersionKind().Empty() {
366+
work.SetGroupVersionKind(workv1alpha1.SchemeGroupVersion.WithKind("Work"))
367+
}
368+
361369
obj, err := helper.ToUnstructured(work)
362370
if err != nil {
363371
return err

0 commit comments

Comments
 (0)