Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ListPods methods to List. #3322

Merged
merged 1 commit into from
Jan 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions pkg/client/cache/listers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ 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 {
Store
}

// 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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/cache/listers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Most consumers should use the Config object to create a Client:
if err != nil {
// handle error
}
client.ListPods()
client.Pods(ns).List()

More advanced consumers may wish to provide their own transport via a http.RoundTripper:

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newPods(c *Client, namespace string) *pods {
}
}

// ListPods takes a selector, and returns the list of pods that match that selector.
// List takes a selector, and returns the list of pods that match that selector.
func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) {
result = &api.PodList{}
err = c.r.Get().Namespace(c.ns).Resource("pods").SelectorParam("labels", selector).Do().Into(result)
Expand Down
2 changes: 1 addition & 1 deletion pkg/clientauth/clientauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Example:
clientConfig.Host = "example.com:4901"
clientConfig = info.MergeWithConfig()
client := client.New(clientConfig)
client.ListPods()
client.Pods(ns).List()
*/
package clientauth

Expand Down
8 changes: 4 additions & 4 deletions pkg/scheduler/listers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func (f FakeMinionLister) List() (api.NodeList, error) {

// PodLister interface represents anything that can list pods for a scheduler.
type PodLister interface {
// TODO: make this exactly the same as client's ListPods() method...
ListPods(labels.Selector) ([]api.Pod, error)
// TODO: make this exactly the same as client's Pods(ns).List() method, by returning a api.PodList
List(labels.Selector) ([]api.Pod, error)
}

// FakePodLister implements PodLister on an []api.Pods for test purposes.
type FakePodLister []api.Pod

// ListPods returns []api.Pod matching a query.
func (f FakePodLister) ListPods(s labels.Selector) (selected []api.Pod, err error) {
// List returns []api.Pod matching a query.
func (f FakePodLister) List(s labels.Selector) (selected []api.Pod, err error) {
for _, pod := range f {
if s.Matches(labels.Set(pod.Labels)) {
selected = append(selected, pod)
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func getUsedPorts(pods ...api.Pod) map[int]bool {
func MapPodsToMachines(lister PodLister) (map[string][]api.Pod, error) {
machineToPods := map[string][]api.Pod{}
// TODO: perform more targeted query...
pods, err := lister.ListPods(labels.Everything())
pods, err := lister.List(labels.Everything())
if err != nil {
return map[string][]api.Pod{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/spreading.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// may not provide optimal spreading for the members of that Service.
// TODO: consider if we want to include Service label sets in the scheduling priority.
func CalculateSpreadPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error) {
pods, err := podLister.ListPods(labels.SelectorFromSet(pod.Labels))
pods, err := podLister.List(labels.SelectorFromSet(pod.Labels))
if err != nil {
return nil, err
}
Expand Down