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:
Eric Tune
2015-01-07 21:57:45 -08:00
parent 6cd37637f5
commit 00c05053b7
8 changed files with 16 additions and 15 deletions

View File

@@ -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)

View File

@@ -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