mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
set RemainingItemCount to ParitalObjectMetadataList
This commit is contained in:
parent
f5be5052e3
commit
45f52321e5
@ -247,6 +247,7 @@ func asPartialObjectMetadataList(result runtime.Object, groupVersion schema.Grou
|
|||||||
list.SelfLink = li.GetSelfLink()
|
list.SelfLink = li.GetSelfLink()
|
||||||
list.ResourceVersion = li.GetResourceVersion()
|
list.ResourceVersion = li.GetResourceVersion()
|
||||||
list.Continue = li.GetContinue()
|
list.Continue = li.GetContinue()
|
||||||
|
list.RemainingItemCount = li.GetRemainingItemCount()
|
||||||
return list, nil
|
return list, nil
|
||||||
|
|
||||||
case groupVersion == metav1.SchemeGroupVersion:
|
case groupVersion == metav1.SchemeGroupVersion:
|
||||||
@ -267,6 +268,7 @@ func asPartialObjectMetadataList(result runtime.Object, groupVersion schema.Grou
|
|||||||
list.SelfLink = li.GetSelfLink()
|
list.SelfLink = li.GetSelfLink()
|
||||||
list.ResourceVersion = li.GetResourceVersion()
|
list.ResourceVersion = li.GetResourceVersion()
|
||||||
list.Continue = li.GetContinue()
|
list.Continue = li.GetContinue()
|
||||||
|
list.RemainingItemCount = li.GetRemainingItemCount()
|
||||||
return list, nil
|
return list, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -171,3 +171,36 @@ func TestCacheableObject(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAsPartialObjectMetadataList(t *testing.T) {
|
||||||
|
var remainingItemCount int64 = 10
|
||||||
|
pods := &examplev1.PodList{
|
||||||
|
ListMeta: metav1.ListMeta{
|
||||||
|
SelfLink: "/test/link",
|
||||||
|
ResourceVersion: "10",
|
||||||
|
Continue: "continuetoken",
|
||||||
|
RemainingItemCount: &remainingItemCount,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pomGVs := []schema.GroupVersion{metav1beta1.SchemeGroupVersion, metav1.SchemeGroupVersion}
|
||||||
|
for _, gv := range pomGVs {
|
||||||
|
t.Run(fmt.Sprintf("as %s PartialObjectMetadataList", gv), func(t *testing.T) {
|
||||||
|
list, err := asPartialObjectMetadataList(pods, gv)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to transform object: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var listMeta metav1.ListMeta
|
||||||
|
switch gv {
|
||||||
|
case metav1beta1.SchemeGroupVersion:
|
||||||
|
listMeta = list.(*metav1beta1.PartialObjectMetadataList).ListMeta
|
||||||
|
case metav1.SchemeGroupVersion:
|
||||||
|
listMeta = list.(*metav1.PartialObjectMetadataList).ListMeta
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(pods.ListMeta, listMeta) {
|
||||||
|
t.Errorf("unexpected list metadata: %v, expected: %v", listMeta, pods.ListMeta)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user