diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index f069d3dc..fbdb499b 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -476,11 +476,11 @@ }, { "ImportPath": "k8s.io/api", - "Rev": "13f29098a509" + "Rev": "8c6483ecf45e" }, { "ImportPath": "k8s.io/apimachinery", - "Rev": "fda713515979" + "Rev": "96c076bf1d97" }, { "ImportPath": "k8s.io/gengo", diff --git a/dynamic/fake/simple.go b/dynamic/fake/simple.go index 1891998f..82f805d1 100644 --- a/dynamic/fake/simple.go +++ b/dynamic/fake/simple.go @@ -115,12 +115,15 @@ type dynamicResourceClient struct { listKind string } +var ( + _ dynamic.Interface = &FakeDynamicClient{} + _ testing.FakeClient = &FakeDynamicClient{} +) + func (c *FakeDynamicClient) Tracker() testing.ObjectTracker { return c.tracker } -var _ dynamic.Interface = &FakeDynamicClient{} - func (c *FakeDynamicClient) Resource(resource schema.GroupVersionResource) dynamic.NamespaceableResourceInterface { return &dynamicResourceClient{client: c, resource: resource, listKind: c.gvrToListKind[resource]} } diff --git a/go.mod b/go.mod index 882649c8..31528740 100644 --- a/go.mod +++ b/go.mod @@ -28,8 +28,8 @@ require ( golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba google.golang.org/protobuf v1.25.0 - k8s.io/api v0.0.0-20210518101607-13f29098a509 - k8s.io/apimachinery v0.0.0-20210518100456-fda713515979 + k8s.io/api v0.0.0-20210506172159-8c6483ecf45e + k8s.io/apimachinery v0.0.0-20210518100457-96c076bf1d97 k8s.io/klog/v2 v2.8.0 k8s.io/utils v0.0.0-20201110183641-67b214c5f920 sigs.k8s.io/structured-merge-diff/v4 v4.1.1 @@ -37,6 +37,6 @@ require ( ) replace ( - k8s.io/api => k8s.io/api v0.0.0-20210518101607-13f29098a509 - k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210518100456-fda713515979 + k8s.io/api => k8s.io/api v0.0.0-20210506172159-8c6483ecf45e + k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210518100457-96c076bf1d97 ) diff --git a/go.sum b/go.sum index 96687c00..1258d8b8 100644 --- a/go.sum +++ b/go.sum @@ -426,10 +426,10 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.0.0-20210518101607-13f29098a509 h1:+1GipftN626FJVaUP8O0o0pgeqGunyS22Ng4hZYulvI= -k8s.io/api v0.0.0-20210518101607-13f29098a509/go.mod h1:IgKLK42qxUHnMxdcdbEBFOo+TfTANemQTLg3gcGe8/M= -k8s.io/apimachinery v0.0.0-20210518100456-fda713515979 h1:qjGp8QxGJZSGSMQw31AFuI2za6IEfDmdJ5/cY+Eeas8= -k8s.io/apimachinery v0.0.0-20210518100456-fda713515979/go.mod h1:fBRSkoylGO2QUTae8Wb2wac6pZ83/r+tL6HFSXGbzfs= +k8s.io/api v0.0.0-20210506172159-8c6483ecf45e h1:qHyhF6qKQVHrfQmOto8W6vEj7OASwoH8x1+p0l/81Dk= +k8s.io/api v0.0.0-20210506172159-8c6483ecf45e/go.mod h1:IgKLK42qxUHnMxdcdbEBFOo+TfTANemQTLg3gcGe8/M= +k8s.io/apimachinery v0.0.0-20210518100457-96c076bf1d97 h1:hKyy5Pr8MoGjcqM5AYHQjpizciRmC8dz4N3XG4LZwuQ= +k8s.io/apimachinery v0.0.0-20210518100457-96c076bf1d97/go.mod h1:fBRSkoylGO2QUTae8Wb2wac6pZ83/r+tL6HFSXGbzfs= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.8.0 h1:Q3gmuM9hKEjefWFFYF0Mat+YyFJvsUyYuwyNNJ5C9Ts= diff --git a/kubernetes/fake/clientset_generated.go b/kubernetes/fake/clientset_generated.go index c09d8999..6f6fc67a 100644 --- a/kubernetes/fake/clientset_generated.go +++ b/kubernetes/fake/clientset_generated.go @@ -158,7 +158,10 @@ func (c *Clientset) Tracker() testing.ObjectTracker { return c.tracker } -var _ clientset.Interface = &Clientset{} +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) // AdmissionregistrationV1 retrieves the AdmissionregistrationV1Client func (c *Clientset) AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1Interface { diff --git a/testing/interface.go b/testing/interface.go new file mode 100644 index 00000000..266c6ba3 --- /dev/null +++ b/testing/interface.go @@ -0,0 +1,66 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testing + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + restclient "k8s.io/client-go/rest" +) + +type FakeClient interface { + // Tracker gives access to the ObjectTracker internal to the fake client. + Tracker() ObjectTracker + + // AddReactor appends a reactor to the end of the chain. + AddReactor(verb, resource string, reaction ReactionFunc) + + // PrependReactor adds a reactor to the beginning of the chain. + PrependReactor(verb, resource string, reaction ReactionFunc) + + // AddWatchReactor appends a reactor to the end of the chain. + AddWatchReactor(resource string, reaction WatchReactionFunc) + + // PrependWatchReactor adds a reactor to the beginning of the chain. + PrependWatchReactor(resource string, reaction WatchReactionFunc) + + // AddProxyReactor appends a reactor to the end of the chain. + AddProxyReactor(resource string, reaction ProxyReactionFunc) + + // PrependProxyReactor adds a reactor to the beginning of the chain. + PrependProxyReactor(resource string, reaction ProxyReactionFunc) + + // Invokes records the provided Action and then invokes the ReactionFunc that + // handles the action if one exists. defaultReturnObj is expected to be of the + // same type a normal call would return. + Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error) + + // InvokesWatch records the provided Action and then invokes the ReactionFunc + // that handles the action if one exists. + InvokesWatch(action Action) (watch.Interface, error) + + // InvokesProxy records the provided Action and then invokes the ReactionFunc + // that handles the action if one exists. + InvokesProxy(action Action) restclient.ResponseWrapper + + // ClearActions clears the history of actions called on the fake client. + ClearActions() + + // Actions returns a chronologically ordered slice fake actions called on the + // fake client. + Actions() []Action +}