set RemainingItemCount to ParitalObjectMetadataList
Kubernetes-commit: 45f52321e52c5e5705a1c7ad3c17e52de262f469
This commit is contained in:
parent
79dcc49bae
commit
7c3ebaea3a
|
@ -247,6 +247,7 @@ func asPartialObjectMetadataList(result runtime.Object, groupVersion schema.Grou
|
|||
list.SelfLink = li.GetSelfLink()
|
||||
list.ResourceVersion = li.GetResourceVersion()
|
||||
list.Continue = li.GetContinue()
|
||||
list.RemainingItemCount = li.GetRemainingItemCount()
|
||||
return list, nil
|
||||
|
||||
case groupVersion == metav1.SchemeGroupVersion:
|
||||
|
@ -267,6 +268,7 @@ func asPartialObjectMetadataList(result runtime.Object, groupVersion schema.Grou
|
|||
list.SelfLink = li.GetSelfLink()
|
||||
list.ResourceVersion = li.GetResourceVersion()
|
||||
list.Continue = li.GetContinue()
|
||||
list.RemainingItemCount = li.GetRemainingItemCount()
|
||||
return list, nil
|
||||
|
||||
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