mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-29 08:29:23 +00:00
Merge pull request #130489 from p0lyn0mial/upstream-fake-client-pass-opts
client-gen/fake: pass ListOptions to Watch method Kubernetes-commit: ea49618a749b84c3cb5bd781380891eb51289950
This commit is contained in:
commit
d5f336d4f5
@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
applyconfigurations "k8s.io/client-go/applyconfigurations"
|
applyconfigurations "k8s.io/client-go/applyconfigurations"
|
||||||
@ -156,9 +157,13 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
|||||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||||
|
var opts metav1.ListOptions
|
||||||
|
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
|
||||||
|
opts = watchActcion.ListOptions
|
||||||
|
}
|
||||||
gvr := action.GetResource()
|
gvr := action.GetResource()
|
||||||
ns := action.GetNamespace()
|
ns := action.GetNamespace()
|
||||||
watch, err := o.Watch(gvr, ns)
|
watch, err := o.Watch(gvr, ns, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@ -205,9 +210,13 @@ func NewClientset(objects ...runtime.Object) *Clientset {
|
|||||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||||
|
var opts metav1.ListOptions
|
||||||
|
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
|
||||||
|
opts = watchActcion.ListOptions
|
||||||
|
}
|
||||||
gvr := action.GetResource()
|
gvr := action.GetResource()
|
||||||
ns := action.GetNamespace()
|
ns := action.GetNamespace()
|
||||||
watch, err := o.Watch(gvr, ns)
|
watch, err := o.Watch(gvr, ns, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user