Implement label queries for controller registry

This commit is contained in:
Daniel Smith 2014-06-16 18:17:08 -07:00
parent 154ec0db1e
commit ad2ec27e91

View File

@ -18,10 +18,10 @@ package registry
import (
"encoding/json"
"net/url"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
// Implementation of RESTStorage for the api server.
@ -35,13 +35,14 @@ func MakeControllerRegistryStorage(registry ControllerRegistry) apiserver.RESTSt
}
}
func (storage *ControllerRegistryStorage) List(*url.URL) (interface{}, error) {
func (storage *ControllerRegistryStorage) List(query labels.Query) (interface{}, error) {
result := api.ReplicationControllerList{JSONBase: api.JSONBase{Kind: "cluster#replicationControllerList"}}
controllers, err := storage.registry.ListControllers()
if err == nil {
result = api.ReplicationControllerList{
JSONBase: api.JSONBase{Kind: "cluster#replicationControllerList"},
Items: controllers,
for _, controller := range controllers {
if query.Matches(labels.LabelSet(controller.Labels)) {
result.Items = append(result.Items, controller)
}
}
}
return result, err