mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Add field selector to List, implement for pods.
This commit is contained in:
@@ -88,7 +88,7 @@ type SimpleRESTStorage struct {
|
||||
injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error)
|
||||
}
|
||||
|
||||
func (storage *SimpleRESTStorage) List(labels.Selector) (runtime.Object, error) {
|
||||
func (storage *SimpleRESTStorage) List(label, field labels.Selector) (runtime.Object, error) {
|
||||
result := &SimpleList{
|
||||
Items: storage.list,
|
||||
}
|
||||
|
@@ -30,8 +30,7 @@ type RESTStorage interface {
|
||||
New() runtime.Object
|
||||
|
||||
// List selects resources in the storage which match to the selector.
|
||||
// TODO: add field selector in addition to label selector.
|
||||
List(labels.Selector) (runtime.Object, error)
|
||||
List(label, field labels.Selector) (runtime.Object, error)
|
||||
|
||||
// Get finds a resource in the storage by id and returns it.
|
||||
// Although it can return an arbitrary error value, IsNotFound(err) is true for the
|
||||
|
@@ -70,12 +70,17 @@ func (h *RESTHandler) handleRESTStorage(parts []string, req *http.Request, w htt
|
||||
case "GET":
|
||||
switch len(parts) {
|
||||
case 1:
|
||||
selector, err := labels.ParseSelector(req.URL.Query().Get("labels"))
|
||||
label, err := labels.ParseSelector(req.URL.Query().Get("labels"))
|
||||
if err != nil {
|
||||
errorJSON(err, h.codec, w)
|
||||
return
|
||||
}
|
||||
list, err := storage.List(selector)
|
||||
field, err := labels.ParseSelector(req.URL.Query().Get("fields"))
|
||||
if err != nil {
|
||||
errorJSON(err, h.codec, w)
|
||||
return
|
||||
}
|
||||
list, err := storage.List(label, field)
|
||||
if err != nil {
|
||||
errorJSON(err, h.codec, w)
|
||||
return
|
||||
|
Reference in New Issue
Block a user