mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #107278 from harsimranmaan/allow_pagination_in_dynamic_fake_lister
Preserve metadata for fake dynamic client unstructured lists
This commit is contained in:
commit
aaee0f57da
@ -387,7 +387,9 @@ func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
list := &unstructured.UnstructuredList{}
|
list := &unstructured.UnstructuredList{}
|
||||||
|
list.SetRemainingItemCount(entireList.GetRemainingItemCount())
|
||||||
list.SetResourceVersion(entireList.GetResourceVersion())
|
list.SetResourceVersion(entireList.GetResourceVersion())
|
||||||
|
list.SetContinue(entireList.GetContinue())
|
||||||
list.GetObjectKind().SetGroupVersionKind(listGVK)
|
list.GetObjectKind().SetGroupVersionKind(listGVK)
|
||||||
for i := range entireList.Items {
|
for i := range entireList.Items {
|
||||||
item := &entireList.Items[i]
|
item := &entireList.Items[i]
|
||||||
|
@ -178,6 +178,7 @@ func Test_ListKind(t *testing.T) {
|
|||||||
"apiVersion": "group/version",
|
"apiVersion": "group/version",
|
||||||
"kind": "TheKindList",
|
"kind": "TheKindList",
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
|
"continue": "",
|
||||||
"resourceVersion": "",
|
"resourceVersion": "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -333,6 +334,7 @@ func TestListWithUnstructuredObjectsAndTypedScheme(t *testing.T) {
|
|||||||
expectedList := &unstructured.UnstructuredList{}
|
expectedList := &unstructured.UnstructuredList{}
|
||||||
expectedList.SetGroupVersionKind(listGVK)
|
expectedList.SetGroupVersionKind(listGVK)
|
||||||
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
||||||
|
expectedList.SetContinue("")
|
||||||
expectedList.Items = append(expectedList.Items, u)
|
expectedList.Items = append(expectedList.Items, u)
|
||||||
|
|
||||||
if diff := cmp.Diff(expectedList, list); diff != "" {
|
if diff := cmp.Diff(expectedList, list); diff != "" {
|
||||||
@ -361,6 +363,7 @@ func TestListWithNoFixturesAndTypedScheme(t *testing.T) {
|
|||||||
expectedList := &unstructured.UnstructuredList{}
|
expectedList := &unstructured.UnstructuredList{}
|
||||||
expectedList.SetGroupVersionKind(listGVK)
|
expectedList.SetGroupVersionKind(listGVK)
|
||||||
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
||||||
|
expectedList.SetContinue("")
|
||||||
|
|
||||||
if diff := cmp.Diff(expectedList, list); diff != "" {
|
if diff := cmp.Diff(expectedList, list); diff != "" {
|
||||||
t.Fatal("unexpected diff (-want, +got): ", diff)
|
t.Fatal("unexpected diff (-want, +got): ", diff)
|
||||||
@ -393,6 +396,7 @@ func TestListWithNoScheme(t *testing.T) {
|
|||||||
expectedList := &unstructured.UnstructuredList{}
|
expectedList := &unstructured.UnstructuredList{}
|
||||||
expectedList.SetGroupVersionKind(listGVK)
|
expectedList.SetGroupVersionKind(listGVK)
|
||||||
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
||||||
|
expectedList.SetContinue("")
|
||||||
expectedList.Items = append(expectedList.Items, u)
|
expectedList.Items = append(expectedList.Items, u)
|
||||||
|
|
||||||
if diff := cmp.Diff(expectedList, list); diff != "" {
|
if diff := cmp.Diff(expectedList, list); diff != "" {
|
||||||
@ -435,6 +439,7 @@ func TestListWithTypedFixtures(t *testing.T) {
|
|||||||
expectedList := &unstructured.UnstructuredList{}
|
expectedList := &unstructured.UnstructuredList{}
|
||||||
expectedList.SetGroupVersionKind(listGVK)
|
expectedList.SetGroupVersionKind(listGVK)
|
||||||
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
expectedList.SetResourceVersion("") // by product of the fake setting resource version
|
||||||
|
expectedList.SetContinue("")
|
||||||
expectedList.Items = []unstructured.Unstructured{u}
|
expectedList.Items = []unstructured.Unstructured{u}
|
||||||
|
|
||||||
if diff := cmp.Diff(expectedList, list); diff != "" {
|
if diff := cmp.Diff(expectedList, list); diff != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user