mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Implement label queries for controller registry
This commit is contained in:
parent
154ec0db1e
commit
ad2ec27e91
@ -18,10 +18,10 @@ package registry
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Implementation of RESTStorage for the api server.
|
// 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"}}
|
result := api.ReplicationControllerList{JSONBase: api.JSONBase{Kind: "cluster#replicationControllerList"}}
|
||||||
controllers, err := storage.registry.ListControllers()
|
controllers, err := storage.registry.ListControllers()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
result = api.ReplicationControllerList{
|
for _, controller := range controllers {
|
||||||
JSONBase: api.JSONBase{Kind: "cluster#replicationControllerList"},
|
if query.Matches(labels.LabelSet(controller.Labels)) {
|
||||||
Items: controllers,
|
result.Items = append(result.Items, controller)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result, err
|
return result, err
|
||||||
|
Loading…
Reference in New Issue
Block a user