Skip to content

Commit 1fb8ed1

Browse files
authored
Merge pull request kubernetes#75993 from caesarxuchao/add-count
Adding RemainingItemCount to ListMeta
2 parents b3a73f7 + d001a0f commit 1fb8ed1

File tree

17 files changed

+321
-223
lines changed

17 files changed

+321
-223
lines changed

api/openapi-spec/swagger.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go

Lines changed: 201 additions & 175 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/meta.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ type ListInterface interface {
9494
SetSelfLink(selfLink string)
9595
GetContinue() string
9696
SetContinue(c string)
97+
GetRemainingItemCount() int64
98+
SetRemainingItemCount(c int64)
9799
}
98100

99101
// Type exposes the type and APIVersion of versioned or internal API objects.
@@ -111,6 +113,8 @@ func (meta *ListMeta) GetSelfLink() string { return meta.SelfLink
111113
func (meta *ListMeta) SetSelfLink(selfLink string) { meta.SelfLink = selfLink }
112114
func (meta *ListMeta) GetContinue() string { return meta.Continue }
113115
func (meta *ListMeta) SetContinue(c string) { meta.Continue = c }
116+
func (meta *ListMeta) GetRemainingItemCount() int64 { return meta.RemainingItemCount }
117+
func (meta *ListMeta) SetRemainingItemCount(c int64) { meta.RemainingItemCount = c }
114118

115119
func (obj *TypeMeta) GetObjectKind() schema.ObjectKind { return obj }
116120

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ type ListMeta struct {
8181
// identical to the value in the first response, unless you have received this token from an error
8282
// message.
8383
Continue string `json:"continue,omitempty" protobuf:"bytes,3,opt,name=continue"`
84+
85+
// RemainingItemCount is the number of subsequent items in the list which are not included in this
86+
// list response. If the list request contained label or field selectors, then the number of
87+
// remaining items is unknown and this field will be unset. If the list is complete (either
88+
// because it is unpaginated or because this is the last page), then there are no more remaining
89+
// items and this field will also be unset. Servers older than v1.15 do not set this field.
90+
// +optional
91+
RemainingItemCount int64 `json:"remainingItemCount,omitempty" protobuf:"bytes,4,opt,name=remainingItemCount"`
8492
}
8593

8694
// These are internal finalizer values for Kubernetes-like APIs, must be qualified name unless defined here

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types_swagger_doc_generated.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ func getNestedString(obj map[string]interface{}, fields ...string) string {
275275
return val
276276
}
277277

278+
func getNestedInt64(obj map[string]interface{}, fields ...string) int64 {
279+
val, found, err := NestedInt64(obj, fields...)
280+
if !found || err != nil {
281+
return 0
282+
}
283+
return val
284+
}
285+
278286
func jsonPath(fields []string) string {
279287
return "." + strings.Join(fields, ".")
280288
}

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ func (u *UnstructuredList) SetContinue(c string) {
166166
u.setNestedField(c, "metadata", "continue")
167167
}
168168

169+
func (u *UnstructuredList) GetRemainingItemCount() int64 {
170+
return getNestedInt64(u.Object, "metadata", "remainingItemCount")
171+
}
172+
173+
func (u *UnstructuredList) SetRemainingItemCount(c int64) {
174+
u.setNestedField(c, "metadata", "remainingItemCount")
175+
}
176+
169177
func (u *UnstructuredList) SetGroupVersionKind(gvk schema.GroupVersionKind) {
170178
u.SetAPIVersion(gvk.GroupVersion().String())
171179
u.SetKind(gvk.Kind)

staging/src/k8s.io/apimachinery/pkg/test/api_meta_meta_test.go

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,28 +193,31 @@ func TestGenericTypeMeta(t *testing.T) {
193193
}
194194

195195
type InternalTypeMeta struct {
196-
Kind string `json:"kind,omitempty"`
197-
Namespace string `json:"namespace,omitempty"`
198-
Name string `json:"name,omitempty"`
199-
GenerateName string `json:"generateName,omitempty"`
200-
UID string `json:"uid,omitempty"`
201-
CreationTimestamp metav1.Time `json:"creationTimestamp,omitempty"`
202-
SelfLink string `json:"selfLink,omitempty"`
203-
ResourceVersion string `json:"resourceVersion,omitempty"`
204-
Continue string `json:"next,omitempty"`
205-
APIVersion string `json:"apiVersion,omitempty"`
206-
Labels map[string]string `json:"labels,omitempty"`
207-
Annotations map[string]string `json:"annotations,omitempty"`
208-
Finalizers []string `json:"finalizers,omitempty"`
209-
OwnerReferences []metav1.OwnerReference `json:"ownerReferences,omitempty"`
196+
Kind string `json:"kind,omitempty"`
197+
Namespace string `json:"namespace,omitempty"`
198+
Name string `json:"name,omitempty"`
199+
GenerateName string `json:"generateName,omitempty"`
200+
UID string `json:"uid,omitempty"`
201+
CreationTimestamp metav1.Time `json:"creationTimestamp,omitempty"`
202+
SelfLink string `json:"selfLink,omitempty"`
203+
ResourceVersion string `json:"resourceVersion,omitempty"`
204+
Continue string `json:"next,omitempty"`
205+
RemainingItemCount int64 `json:"remainingItemCount,omitempty"`
206+
APIVersion string `json:"apiVersion,omitempty"`
207+
Labels map[string]string `json:"labels,omitempty"`
208+
Annotations map[string]string `json:"annotations,omitempty"`
209+
Finalizers []string `json:"finalizers,omitempty"`
210+
OwnerReferences []metav1.OwnerReference `json:"ownerReferences,omitempty"`
210211
}
211212

212-
func (m *InternalTypeMeta) GetResourceVersion() string { return m.ResourceVersion }
213-
func (m *InternalTypeMeta) SetResourceVersion(rv string) { m.ResourceVersion = rv }
214-
func (m *InternalTypeMeta) GetSelfLink() string { return m.SelfLink }
215-
func (m *InternalTypeMeta) SetSelfLink(link string) { m.SelfLink = link }
216-
func (m *InternalTypeMeta) GetContinue() string { return m.Continue }
217-
func (m *InternalTypeMeta) SetContinue(c string) { m.Continue = c }
213+
func (m *InternalTypeMeta) GetResourceVersion() string { return m.ResourceVersion }
214+
func (m *InternalTypeMeta) SetResourceVersion(rv string) { m.ResourceVersion = rv }
215+
func (m *InternalTypeMeta) GetSelfLink() string { return m.SelfLink }
216+
func (m *InternalTypeMeta) SetSelfLink(link string) { m.SelfLink = link }
217+
func (m *InternalTypeMeta) GetContinue() string { return m.Continue }
218+
func (m *InternalTypeMeta) SetContinue(c string) { m.Continue = c }
219+
func (m *InternalTypeMeta) GetRemainingItemCount() int64 { return m.RemainingItemCount }
220+
func (m *InternalTypeMeta) SetRemainingItemCount(c int64) { m.RemainingItemCount = c }
218221

219222
type MyAPIObject struct {
220223
TypeMeta InternalTypeMeta `json:",inline"`

0 commit comments

Comments
 (0)