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:
Kubernetes Prow Robot 2022-10-17 13:09:18 -07:00 committed by GitHub
commit aaee0f57da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -387,7 +387,9 @@ func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOption
}
list := &unstructured.UnstructuredList{}
list.SetRemainingItemCount(entireList.GetRemainingItemCount())
list.SetResourceVersion(entireList.GetResourceVersion())
list.SetContinue(entireList.GetContinue())
list.GetObjectKind().SetGroupVersionKind(listGVK)
for i := range entireList.Items {
item := &entireList.Items[i]

View File

@ -178,6 +178,7 @@ func Test_ListKind(t *testing.T) {
"apiVersion": "group/version",
"kind": "TheKindList",
"metadata": map[string]interface{}{
"continue": "",
"resourceVersion": "",
},
},
@ -333,6 +334,7 @@ func TestListWithUnstructuredObjectsAndTypedScheme(t *testing.T) {
expectedList := &unstructured.UnstructuredList{}
expectedList.SetGroupVersionKind(listGVK)
expectedList.SetResourceVersion("") // by product of the fake setting resource version
expectedList.SetContinue("")
expectedList.Items = append(expectedList.Items, u)
if diff := cmp.Diff(expectedList, list); diff != "" {
@ -361,6 +363,7 @@ func TestListWithNoFixturesAndTypedScheme(t *testing.T) {
expectedList := &unstructured.UnstructuredList{}
expectedList.SetGroupVersionKind(listGVK)
expectedList.SetResourceVersion("") // by product of the fake setting resource version
expectedList.SetContinue("")
if diff := cmp.Diff(expectedList, list); diff != "" {
t.Fatal("unexpected diff (-want, +got): ", diff)
@ -393,6 +396,7 @@ func TestListWithNoScheme(t *testing.T) {
expectedList := &unstructured.UnstructuredList{}
expectedList.SetGroupVersionKind(listGVK)
expectedList.SetResourceVersion("") // by product of the fake setting resource version
expectedList.SetContinue("")
expectedList.Items = append(expectedList.Items, u)
if diff := cmp.Diff(expectedList, list); diff != "" {
@ -435,6 +439,7 @@ func TestListWithTypedFixtures(t *testing.T) {
expectedList := &unstructured.UnstructuredList{}
expectedList.SetGroupVersionKind(listGVK)
expectedList.SetResourceVersion("") // by product of the fake setting resource version
expectedList.SetContinue("")
expectedList.Items = []unstructured.Unstructured{u}
if diff := cmp.Diff(expectedList, list); diff != "" {