Skip to content

Commit

Permalink
Merge pull request #608 from rajathagasthya/listopts
Browse files Browse the repository at this point in the history
🐛 Set limit and continue in ApplyToList method
  • Loading branch information
k8s-ci-robot authored Sep 18, 2019
2 parents e96f830 + 6b91e8e commit 801e12a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ func (o *ListOptions) ApplyToList(lo *ListOptions) {
if o.Raw != nil {
lo.Raw = o.Raw
}
if o.Limit > 0 {
lo.Limit = o.Limit
}
if o.Continue != "" {
lo.Continue = o.Continue
}
}

// AsListOptions returns these options as a flattened metav1.ListOptions.
Expand Down
12 changes: 12 additions & 0 deletions pkg/client/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ var _ = Describe("ListOptions", func() {
o.ApplyToList(newListOpts)
Expect(newListOpts).To(Equal(o))
})
It("Should set Limit", func() {
o := &client.ListOptions{Limit: int64(1)}
newListOpts := &client.ListOptions{}
o.ApplyToList(newListOpts)
Expect(newListOpts).To(Equal(o))
})
It("Should set Continue", func() {
o := &client.ListOptions{Continue: "foo"}
newListOpts := &client.ListOptions{}
o.ApplyToList(newListOpts)
Expect(newListOpts).To(Equal(o))
})
It("Should not set anything", func() {
o := &client.ListOptions{}
newListOpts := &client.ListOptions{}
Expand Down

0 comments on commit 801e12a

Please sign in to comment.