Skip to content

Commit 801e12a

Browse files
authored
Merge pull request #608 from rajathagasthya/listopts
🐛 Set limit and continue in ApplyToList method
2 parents e96f830 + 6b91e8e commit 801e12a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/client/options.go

+6
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ func (o *ListOptions) ApplyToList(lo *ListOptions) {
336336
if o.Raw != nil {
337337
lo.Raw = o.Raw
338338
}
339+
if o.Limit > 0 {
340+
lo.Limit = o.Limit
341+
}
342+
if o.Continue != "" {
343+
lo.Continue = o.Continue
344+
}
339345
}
340346

341347
// AsListOptions returns these options as a flattened metav1.ListOptions.

pkg/client/options_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ var _ = Describe("ListOptions", func() {
5454
o.ApplyToList(newListOpts)
5555
Expect(newListOpts).To(Equal(o))
5656
})
57+
It("Should set Limit", func() {
58+
o := &client.ListOptions{Limit: int64(1)}
59+
newListOpts := &client.ListOptions{}
60+
o.ApplyToList(newListOpts)
61+
Expect(newListOpts).To(Equal(o))
62+
})
63+
It("Should set Continue", func() {
64+
o := &client.ListOptions{Continue: "foo"}
65+
newListOpts := &client.ListOptions{}
66+
o.ApplyToList(newListOpts)
67+
Expect(newListOpts).To(Equal(o))
68+
})
5769
It("Should not set anything", func() {
5870
o := &client.ListOptions{}
5971
newListOpts := &client.ListOptions{}

0 commit comments

Comments
 (0)