Add field selector to List, implement for pods.
This commit is contained in:
@@ -97,14 +97,17 @@ func (rs *REST) Get(id string) (runtime.Object, error) {
|
||||
}
|
||||
|
||||
// List obtains a list of ReplicationControllers that match selector.
|
||||
func (rs *REST) List(selector labels.Selector) (runtime.Object, error) {
|
||||
func (rs *REST) List(label, field labels.Selector) (runtime.Object, error) {
|
||||
if !field.Empty() {
|
||||
return nil, fmt.Errorf("field selector not supported yet")
|
||||
}
|
||||
controllers, err := rs.registry.ListControllers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
filtered := []api.ReplicationController{}
|
||||
for _, controller := range controllers.Items {
|
||||
if selector.Matches(labels.Set(controller.Labels)) {
|
||||
if label.Matches(labels.Set(controller.Labels)) {
|
||||
rs.fillCurrentState(&controller)
|
||||
filtered = append(filtered, controller)
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ func TestListControllersError(t *testing.T) {
|
||||
storage := REST{
|
||||
registry: &mockRegistry,
|
||||
}
|
||||
controllers, err := storage.List(nil)
|
||||
controllers, err := storage.List(labels.Everything(), labels.Everything())
|
||||
if err != mockRegistry.Err {
|
||||
t.Errorf("Expected %#v, Got %#v", mockRegistry.Err, err)
|
||||
}
|
||||
@@ -53,7 +53,7 @@ func TestListEmptyControllerList(t *testing.T) {
|
||||
storage := REST{
|
||||
registry: &mockRegistry,
|
||||
}
|
||||
controllers, err := storage.List(labels.Everything())
|
||||
controllers, err := storage.List(labels.Everything(), labels.Everything())
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func TestListControllerList(t *testing.T) {
|
||||
storage := REST{
|
||||
registry: &mockRegistry,
|
||||
}
|
||||
controllersObj, err := storage.List(labels.Everything())
|
||||
controllersObj, err := storage.List(labels.Everything(), labels.Everything())
|
||||
controllers := controllersObj.(*api.ReplicationControllerList)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
Reference in New Issue
Block a user