mirror of
https://github.com/kubernetes/sample-controller.git
synced 2025-03-07 02:51:07 +08:00

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. feat(fakeclient): push event on watched channel on add/update/delete **What this PR does / why we need it**: This PR enables watch function for kubernetes [fakeclient](1bcf0b0a22/staging/src/k8s.io/client-go/kubernetes/fake/clientset_generated.go (L88)
). This fake client add watchReactorFunction by wrapping [watch.NewFake](1bcf0b0a22/staging/src/k8s.io/client-go/kubernetes/fake/clientset_generated.go (L98)
) which is a `chan Event` but actually nothing pushes objects into this channel. So all watch function called by fake client will never return or never receive any object. This PR intercepts ReactionFunc of `Create / Update / DeleteActionImpl` and will push the requested object to channel. Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #54075 **Special notes for your reviewer**: **Release note**: ```dev-release-note enable watch function for fake client ``` Kubernetes-commit: 268555a30a0f028762854f5b0d3ebb587e2ee4ee