Merge pull request #96020 from deads2k/dynamiclist
update fake dynamic client to return GVK Kubernetes-commit: dbd2be08fb0515599aadb897e0c1476abc8b2552
This commit is contained in:
commit
7663a9f447
|
|
@ -768,7 +768,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery",
|
||||
"Rev": "79ef3cbd919a"
|
||||
"Rev": "d67967d70958"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/cli-runtime",
|
||||
|
|
@ -776,7 +776,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go",
|
||||
"Rev": "bcecfeab186d"
|
||||
"Rev": "1eb2027cd51e"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/code-generator",
|
||||
|
|
|
|||
8
go.mod
8
go.mod
|
|
@ -35,9 +35,9 @@ require (
|
|||
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
k8s.io/api v0.0.0-20201104162213-01c5338f427f
|
||||
k8s.io/apimachinery v0.0.0-20201104162036-79ef3cbd919a
|
||||
k8s.io/apimachinery v0.0.0-20201105042036-d67967d70958
|
||||
k8s.io/cli-runtime v0.0.0-20201104164157-a3f7397dc36e
|
||||
k8s.io/client-go v0.0.0-20201105002432-bcecfeab186d
|
||||
k8s.io/client-go v0.0.0-20201105042428-1eb2027cd51e
|
||||
k8s.io/component-base v0.0.0-20201104162905-3f97287498d9
|
||||
k8s.io/component-helpers v0.0.0-20201104163002-2a464068d690
|
||||
k8s.io/klog/v2 v2.4.0
|
||||
|
|
@ -50,9 +50,9 @@ require (
|
|||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20201104162213-01c5338f427f
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20201104162036-79ef3cbd919a
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20201105042036-d67967d70958
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20201104164157-a3f7397dc36e
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20201105002432-bcecfeab186d
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20201105042428-1eb2027cd51e
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20201104161901-3609764c976f
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20201104162905-3f97287498d9
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20201104163002-2a464068d690
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -509,9 +509,9 @@ 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=
|
||||
k8s.io/api v0.0.0-20201104162213-01c5338f427f/go.mod h1:5iJ2LFNvkNfwL+E+lMewJWlnnT3Fpj1BYHa2Qb4fjrI=
|
||||
k8s.io/apimachinery v0.0.0-20201104162036-79ef3cbd919a/go.mod h1:WC5jfah6jg0OD6SE11oSOCQHkfkLh7pwIYbwS/dZLe4=
|
||||
k8s.io/apimachinery v0.0.0-20201105042036-d67967d70958/go.mod h1:WC5jfah6jg0OD6SE11oSOCQHkfkLh7pwIYbwS/dZLe4=
|
||||
k8s.io/cli-runtime v0.0.0-20201104164157-a3f7397dc36e/go.mod h1:OIreMxwQxdN+VlCRrpYdWuKa3nz8exog4wSSdmXngbQ=
|
||||
k8s.io/client-go v0.0.0-20201105002432-bcecfeab186d/go.mod h1:ztJbR1F/dNgUooItME/OBnPPJ7txxpzXUb7zQ7yZRv8=
|
||||
k8s.io/client-go v0.0.0-20201105042428-1eb2027cd51e/go.mod h1:Uk/f7lE00tI0bzmlKkW6JIIYZkqd8dFonXGaHo46ya0=
|
||||
k8s.io/code-generator v0.0.0-20201104161901-3609764c976f/go.mod h1:XBVD9f8PJVt5zdhi95/mi/yGQEn1GSqbrfD17zGD/l4=
|
||||
k8s.io/component-base v0.0.0-20201104162905-3f97287498d9/go.mod h1:e91J0JFtlK6KYq5IkdK6rjMoeeEZ68YnyCVaCUkVQuo=
|
||||
k8s.io/component-helpers v0.0.0-20201104163002-2a464068d690/go.mod h1:FMntmyDIm1iLTi5gEQ5hKfovf7cGLvAKBX/66698Z4Q=
|
||||
|
|
|
|||
|
|
@ -82,6 +82,11 @@ func addCondition(in *unstructured.Unstructured, name, status string) *unstructu
|
|||
|
||||
func TestWaitForDeletion(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
listMapping := map[schema.GroupVersionResource]string{
|
||||
{Group: "group", Version: "version", Resource: "theresource"}: "TheKindList",
|
||||
{Group: "group", Version: "version", Resource: "theresource-1"}: "TheKindList",
|
||||
{Group: "group", Version: "version", Resource: "theresource-2"}: "TheKindList",
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -105,7 +110,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
return dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
return dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
},
|
||||
timeout: 10 * time.Second,
|
||||
|
||||
|
|
@ -145,7 +150,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")), nil
|
||||
})
|
||||
|
|
@ -192,7 +197,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")), nil
|
||||
})
|
||||
|
|
@ -225,7 +230,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
unstructuredObj := newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")
|
||||
unstructuredObj.SetResourceVersion("123")
|
||||
|
|
@ -282,7 +287,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")), nil
|
||||
})
|
||||
|
|
@ -326,7 +331,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("get", "theresource-1", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructured("group/version", "TheKind", "ns-foo", "name-foo-1"), nil
|
||||
})
|
||||
|
|
@ -371,7 +376,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")), nil
|
||||
})
|
||||
|
|
@ -449,6 +454,9 @@ func TestWaitForDeletion(t *testing.T) {
|
|||
|
||||
func TestWaitForCondition(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
listMapping := map[schema.GroupVersionResource]string{
|
||||
{Group: "group", Version: "version", Resource: "theresource"}: "TheKindList",
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -471,7 +479,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(addCondition(
|
||||
newUnstructured("group/version", "TheKind", "ns-foo", "name-foo"),
|
||||
|
|
@ -517,7 +525,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
return dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
return dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
},
|
||||
timeout: 10 * time.Second,
|
||||
expectedErr: "resource name must be provided",
|
||||
|
|
@ -540,7 +548,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, addCondition(
|
||||
newUnstructured("group/version", "TheKind", "ns-foo", "name-foo"),
|
||||
|
|
@ -576,7 +584,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
unstructuredObj := newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")
|
||||
unstructuredObj.SetResourceVersion("123")
|
||||
|
|
@ -633,7 +641,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")), nil
|
||||
})
|
||||
|
|
@ -673,7 +681,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependWatchReactor("theresource", func(action clienttesting.Action) (handled bool, ret watch.Interface, err error) {
|
||||
fakeWatch := watch.NewRaceFreeFake()
|
||||
fakeWatch.Action(watch.Added, addCondition(
|
||||
|
|
@ -710,7 +718,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||
},
|
||||
},
|
||||
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
fakeClient.PrependReactor("list", "theresource", func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
|
||||
return true, newUnstructuredList(newUnstructured("group/version", "TheKind", "ns-foo", "name-foo")), nil
|
||||
})
|
||||
|
|
@ -790,6 +798,9 @@ func TestWaitForCondition(t *testing.T) {
|
|||
|
||||
func TestWaitForDeletionIgnoreNotFound(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
listMapping := map[schema.GroupVersionResource]string{
|
||||
{Group: "group", Version: "version", Resource: "theresource"}: "TheKindList",
|
||||
}
|
||||
infos := []*resource.Info{
|
||||
{
|
||||
Mapping: &meta.RESTMapping{
|
||||
|
|
@ -799,7 +810,7 @@ func TestWaitForDeletionIgnoreNotFound(t *testing.T) {
|
|||
Namespace: "ns-foo",
|
||||
},
|
||||
}
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
|
||||
o := &WaitOptions{
|
||||
ResourceFinder: genericclioptions.NewSimpleFakeResourceFinder(infos...),
|
||||
|
|
|
|||
Loading…
Reference in New Issue