mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Implement label queries for controller registry
This commit is contained in:
parent
154ec0db1e
commit
ad2ec27e91
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user