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

Unify List() signature in clients #16589

Merged
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
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/service/endpoints_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pkg/client/unversioned/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/client/unversioned/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/client/unversioned/testclient/fake_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/endpoint/endpoints_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/service_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down