FieldSelector for node List()

This commit is contained in:
Wojciech Tyczynski
2015-04-10 12:08:36 +02:00
parent 8510fc67ff
commit 88eb0b0295
14 changed files with 27 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ type NodesInterface interface {
type NodeInterface interface {
Get(name string) (result *api.Node, err error)
Create(node *api.Node) (*api.Node, error)
List(selector labels.Selector) (*api.NodeList, error)
List(label labels.Selector, field fields.Selector) (*api.NodeList, error)
Delete(name string) error
Update(*api.Node) (*api.Node, error)
UpdateStatus(*api.Node) (*api.Node, error)
@@ -66,9 +66,9 @@ func (c *nodes) Create(node *api.Node) (*api.Node, error) {
}
// List takes a selector, and returns the list of nodes that match that selector in the cluster.
func (c *nodes) List(selector labels.Selector) (*api.NodeList, error) {
func (c *nodes) List(label labels.Selector, field fields.Selector) (*api.NodeList, error) {
result := &api.NodeList{}
err := c.r.Get().Resource(c.resourceName()).LabelsSelectorParam(selector).Do().Into(result)
err := c.r.Get().Resource(c.resourceName()).LabelsSelectorParam(label).FieldsSelectorParam(field).Do().Into(result)
return result, err
}

View File

@@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
@@ -41,7 +42,7 @@ func TestListMinions(t *testing.T) {
},
Response: Response{StatusCode: 200, Body: &api.NodeList{ListMeta: api.ListMeta{ResourceVersion: "1"}}},
}
response, err := c.Setup().Nodes().List(labels.Everything())
response, err := c.Setup().Nodes().List(labels.Everything(), fields.Everything())
c.Validate(t, response, err)
}
@@ -72,7 +73,7 @@ func TestListMinionsLabels(t *testing.T) {
c.Setup()
c.QueryValidator[labelSelectorQueryParamName] = validateLabels
selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector()
receivedNodeList, err := c.Nodes().List(selector)
receivedNodeList, err := c.Nodes().List(selector, fields.Everything())
c.Validate(t, receivedNodeList, err)
}

View File

@@ -34,7 +34,7 @@ func (c *FakeNodes) Get(name string) (*api.Node, error) {
return obj.(*api.Node), err
}
func (c *FakeNodes) List(selector labels.Selector) (*api.NodeList, error) {
func (c *FakeNodes) List(label labels.Selector, field fields.Selector) (*api.NodeList, error) {
obj, err := c.Fake.Invokes(FakeAction{Action: "list-nodes"}, &api.NodeList{})
return obj.(*api.NodeList), err
}