mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-31 23:00:26 +00:00
Merge pull request #105387 from howardjohn/metadata-client/tracker
Make metadata fake client implement testing.FakeClient Kubernetes-commit: 35c8975710e9cc50a0fc14383d1004dde86c854e
This commit is contained in:
commit
07be351f6b
4
go.mod
4
go.mod
@ -30,7 +30,7 @@ require (
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
|
||||
google.golang.org/protobuf v1.27.1
|
||||
k8s.io/api v0.0.0-20220113211846-a75b0b5d422b
|
||||
k8s.io/api v0.0.0-20220113211846-688ca8d0fa27
|
||||
k8s.io/apimachinery v0.0.0-20220113183030-80d954b85ad3
|
||||
k8s.io/klog/v2 v2.40.1
|
||||
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65
|
||||
@ -40,6 +40,6 @@ require (
|
||||
)
|
||||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20220113211846-a75b0b5d422b
|
||||
k8s.io/api => k8s.io/api v0.0.0-20220113211846-688ca8d0fa27
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220113183030-80d954b85ad3
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -610,8 +610,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
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=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20220113211846-a75b0b5d422b h1:8fkYzgrIFpR9JQUPkZtPVhyutH6nOxIidTDLS4wiXBk=
|
||||
k8s.io/api v0.0.0-20220113211846-a75b0b5d422b/go.mod h1:fUvEeJsH9l+ZxaqspWiBMGy+KsoIBu5lrLGsqP0ObNs=
|
||||
k8s.io/api v0.0.0-20220113211846-688ca8d0fa27 h1:f8r5a/34RUVPT61kPSZ9NTGCL9kbob8EWtHfJnteL7o=
|
||||
k8s.io/api v0.0.0-20220113211846-688ca8d0fa27/go.mod h1:fUvEeJsH9l+ZxaqspWiBMGy+KsoIBu5lrLGsqP0ObNs=
|
||||
k8s.io/apimachinery v0.0.0-20220113183030-80d954b85ad3 h1:sGOAAwlC7JwTwyesgXqg74tNpB6Qf+dULzBRoyVToCE=
|
||||
k8s.io/apimachinery v0.0.0-20220113183030-80d954b85ad3/go.mod h1:vcZg0n5bcYADuuKUza0y2en2OCM/UIxFaAI7N0cN6Ik=
|
||||
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
|
@ -60,7 +60,7 @@ func NewSimpleMetadataClient(scheme *runtime.Scheme, objects ...runtime.Object)
|
||||
}
|
||||
}
|
||||
|
||||
cs := &FakeMetadataClient{scheme: scheme}
|
||||
cs := &FakeMetadataClient{scheme: scheme, tracker: o}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
@ -80,7 +80,8 @@ func NewSimpleMetadataClient(scheme *runtime.Scheme, objects ...runtime.Object)
|
||||
// you want to test easier.
|
||||
type FakeMetadataClient struct {
|
||||
testing.Fake
|
||||
scheme *runtime.Scheme
|
||||
scheme *runtime.Scheme
|
||||
tracker testing.ObjectTracker
|
||||
}
|
||||
|
||||
type metadataResourceClient struct {
|
||||
@ -89,7 +90,14 @@ type metadataResourceClient struct {
|
||||
resource schema.GroupVersionResource
|
||||
}
|
||||
|
||||
var _ metadata.Interface = &FakeMetadataClient{}
|
||||
var (
|
||||
_ metadata.Interface = &FakeMetadataClient{}
|
||||
_ testing.FakeClient = &FakeMetadataClient{}
|
||||
)
|
||||
|
||||
func (c *FakeMetadataClient) Tracker() testing.ObjectTracker {
|
||||
return c.tracker
|
||||
}
|
||||
|
||||
// Resource returns an interface for accessing the provided resource.
|
||||
func (c *FakeMetadataClient) Resource(resource schema.GroupVersionResource) metadata.Getter {
|
||||
|
Loading…
Reference in New Issue
Block a user