Unify List() signature in clients

pull/6/head
Wojciech Tyczynski 2015-10-30 15:35:22 +01:00
parent cc53619372
commit aac55d4795
8 changed files with 13 additions and 11 deletions

View File

@ -384,7 +384,7 @@ func (e *endpointController) syncService(key string) {
// some stragglers could have been left behind if the endpoint controller
// reboots).
func (e *endpointController) checkLeftoverEndpoints() {
list, err := e.client.Endpoints(api.NamespaceAll).List(labels.Everything())
list, err := e.client.Endpoints(api.NamespaceAll).List(labels.Everything(), fields.Everything())
if err != nil {
glog.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err)
return

View File

@ -33,7 +33,7 @@ type EndpointsNamespacer interface {
// EndpointsInterface has methods to work with Endpoints resources
type EndpointsInterface interface {
Create(endpoints *api.Endpoints) (*api.Endpoints, error)
List(selector labels.Selector) (*api.EndpointsList, error)
List(label labels.Selector, field fields.Selector) (*api.EndpointsList, error)
Get(name string) (*api.Endpoints, error)
Delete(name string) error
Update(endpoints *api.Endpoints) (*api.Endpoints, error)
@ -59,12 +59,13 @@ func (c *endpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error) {
}
// List takes a selector, and returns the list of endpoints that match that selector
func (c *endpoints) List(selector labels.Selector) (result *api.EndpointsList, err error) {
func (c *endpoints) List(label labels.Selector, field fields.Selector) (result *api.EndpointsList, err error) {
result = &api.EndpointsList{}
err = c.r.Get().
Namespace(c.ns).
Resource("endpoints").
LabelsSelectorParam(selector).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Do().
Into(result)
return

View File

@ -21,6 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
)
@ -42,7 +43,7 @@ func TestListEndpoints(t *testing.T) {
},
},
}
receivedEndpointsList, err := c.Setup(t).Endpoints(ns).List(labels.Everything())
receivedEndpointsList, err := c.Setup(t).Endpoints(ns).List(labels.Everything(), fields.Everything())
c.Validate(t, receivedEndpointsList, err)
}

View File

@ -39,8 +39,8 @@ func (c *FakeEndpoints) Get(name string) (*api.Endpoints, error) {
return obj.(*api.Endpoints), err
}
func (c *FakeEndpoints) List(label labels.Selector) (*api.EndpointsList, error) {
obj, err := c.Fake.Invokes(NewListAction("endpoints", c.Namespace, label, nil), &api.EndpointsList{})
func (c *FakeEndpoints) List(label labels.Selector, field fields.Selector) (*api.EndpointsList, error) {
obj, err := c.Fake.Invokes(NewListAction("endpoints", c.Namespace, label, field), &api.EndpointsList{})
if obj == nil {
return nil, err
}

View File

@ -384,7 +384,7 @@ func (e *EndpointController) syncService(key string) {
// some stragglers could have been left behind if the endpoint controller
// reboots).
func (e *EndpointController) checkLeftoverEndpoints() {
list, err := e.client.Endpoints(api.NamespaceAll).List(labels.Everything())
list, err := e.client.Endpoints(api.NamespaceAll).List(labels.Everything(), fields.Everything())
if err != nil {
glog.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err)
return

View File

@ -139,7 +139,7 @@ func (f *Framework) WaitForAnEndpoint(serviceName string) error {
for {
// TODO: Endpoints client should take a field selector so we
// don't have to list everything.
list, err := f.Client.Endpoints(f.Namespace.Name).List(labels.Everything())
list, err := f.Client.Endpoints(f.Namespace.Name).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}

View File

@ -279,7 +279,7 @@ func startEndpointWatcher(f *Framework, q *endpointQueries) {
_, controller := framework.NewInformer(
&cache.ListWatch{
ListFunc: func() (runtime.Object, error) {
return f.Client.Endpoints(f.Namespace.Name).List(labels.Everything())
return f.Client.Endpoints(f.Namespace.Name).List(labels.Everything(), fields.Everything())
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return f.Client.Endpoints(f.Namespace.Name).Watch(labels.Everything(), fields.Everything(), options)

View File

@ -705,7 +705,7 @@ func waitForService(c *client.Client, namespace, name string, exist bool, interv
func waitForServiceEndpointsNum(c *client.Client, namespace, serviceName string, expectNum int, interval, timeout time.Duration) error {
return wait.Poll(interval, timeout, func() (bool, error) {
Logf("Waiting for amount of service:%s endpoints to %d", serviceName, expectNum)
list, err := c.Endpoints(namespace).List(labels.Everything())
list, err := c.Endpoints(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return false, err
}