mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 12:11:43 +00:00
Rename ListPods methods to List.
For greater similarity to pkg/client. Does not cover registry's ListPods. Fix an example in a comment.
This commit is contained in:
11
pkg/client/cache/listers.go
vendored
11
pkg/client/cache/listers.go
vendored
@@ -31,7 +31,8 @@ import (
|
||||
//
|
||||
// Example:
|
||||
// s := cache.NewStore()
|
||||
// XXX NewReflector(... s ...)
|
||||
// lw := cache.ListWatch{Client: c, FieldSelector: sel, Resource: "pods"}
|
||||
// r := cache.NewReflector(lw, &api.Pod{}, s).Run()
|
||||
// l := StoreToPodLister{s}
|
||||
// l.List()
|
||||
type StoreToPodLister struct {
|
||||
@@ -39,10 +40,10 @@ type StoreToPodLister struct {
|
||||
}
|
||||
|
||||
// TODO Get rid of the selector because that is confusing because the user might not realize that there has already been
|
||||
// some selection at the caching stage. Also, consistency will facilitate code generation.
|
||||
// TODO: Rename to List() instead of ListPods() for consistency with other resources and with pkg/client..
|
||||
func (s *StoreToPodLister) ListPods(selector labels.Selector) (pods []api.Pod, err error) {
|
||||
for _, m := range s.List() {
|
||||
// some selection at the caching stage. Also, consistency will facilitate code generation. However, the pkg/client
|
||||
// is inconsistent too.
|
||||
func (s *StoreToPodLister) List(selector labels.Selector) (pods []api.Pod, err error) {
|
||||
for _, m := range s.Store.List() {
|
||||
pod := m.(*api.Pod)
|
||||
if selector.Matches(labels.Set(pod.Labels)) {
|
||||
pods = append(pods, *pod)
|
||||
|
2
pkg/client/cache/listers_test.go
vendored
2
pkg/client/cache/listers_test.go
vendored
@@ -59,7 +59,7 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
spl := StoreToPodLister{store}
|
||||
|
||||
for _, id := range ids {
|
||||
got, err := spl.ListPods(labels.Set{"name": id}.AsSelector())
|
||||
got, err := spl.List(labels.Set{"name": id}.AsSelector())
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
continue
|
||||
|
Reference in New Issue
Block a user