mirror of
https://github.com/rancher/steve.git
synced 2025-07-01 01:02:08 +00:00
30 lines
801 B
Go
30 lines
801 B
Go
|
package selector
|
||
|
|
||
|
import (
|
||
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
||
|
"k8s.io/apimachinery/pkg/labels"
|
||
|
)
|
||
|
|
||
|
type Store struct {
|
||
|
types.Store
|
||
|
Selector labels.Selector
|
||
|
}
|
||
|
|
||
|
func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.APIObjectList, error) {
|
||
|
return s.Store.List(s.addSelector(apiOp), schema)
|
||
|
}
|
||
|
|
||
|
func (s *Store) addSelector(apiOp *types.APIRequest) *types.APIRequest {
|
||
|
|
||
|
apiOp = apiOp.Clone()
|
||
|
apiOp.Request = apiOp.Request.Clone(apiOp.Context())
|
||
|
q := apiOp.Request.URL.Query()
|
||
|
q.Add("labelSelector", s.Selector.String())
|
||
|
apiOp.Request.URL.RawQuery = q.Encode()
|
||
|
return apiOp
|
||
|
}
|
||
|
|
||
|
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
|
||
|
return s.Store.Watch(s.addSelector(apiOp), schema, w)
|
||
|
}
|