diff --git a/pkg/api/rest/rest.go b/pkg/api/rest/rest.go index 55bfa60f70c..2308876b7eb 100644 --- a/pkg/api/rest/rest.go +++ b/pkg/api/rest/rest.go @@ -22,8 +22,6 @@ import ( "net/url" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/watch" ) @@ -62,8 +60,7 @@ type Lister interface { // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object) NewList() runtime.Object // List selects resources in the storage which match to the selector. 'options' can be nil. - // TODO: Move 'label' and 'field' to 'options'. - List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) + List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) } // Getter is an object that can retrieve a named RESTful resource. @@ -184,8 +181,7 @@ type Watcher interface { // are supported; an error should be returned if 'field' tries to select on a field that // isn't supported. 'resourceVersion' allows for continuing/starting a watch at a // particular version. - // TODO: Replace 'label', 'field' and 'resourceVersion' with ListOptions. - Watch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) + Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) } // StandardStorage is an interface covering the common verbs. Provided for testing whether a diff --git a/pkg/api/rest/resttest/resttest.go b/pkg/api/rest/resttest/resttest.go index db223d90688..d6884445615 100644 --- a/pkg/api/rest/resttest/resttest.go +++ b/pkg/api/rest/resttest/resttest.go @@ -853,7 +853,7 @@ func (t *Tester) testListError() { storageError := fmt.Errorf("test error") t.withStorageError(storageError, func() { - _, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything(), nil) + _, err := t.storage.(rest.Lister).List(ctx, nil) if err != storageError { t.Errorf("unexpected error: %v", err) } @@ -870,7 +870,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) { existing := assignFn([]runtime.Object{foo1, foo2}) - listObj, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything(), nil) + listObj, err := t.storage.(rest.Lister).List(ctx, nil) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -902,7 +902,8 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) { filtered := []runtime.Object{existing[1]} selector := labels.SelectorFromSet(labels.Set(testLabels)) - listObj, err := t.storage.(rest.Lister).List(ctx, selector, fields.Everything(), nil) + options := &api.ListOptions{LabelSelector: selector} + listObj, err := t.storage.(rest.Lister).List(ctx, options) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -924,7 +925,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) { setRVFn(uint64(123)) _ = assignFn([]runtime.Object{}) - listObj, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything(), nil) + listObj, err := t.storage.(rest.Lister).List(ctx, nil) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -950,7 +951,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) { func (t *Tester) testWatch(initWatchFn InitWatchFunc, injectErrFn InjectErrFunc) { ctx := t.TestContext() - watcher, err := t.storage.(rest.Watcher).Watch(ctx, labels.Everything(), fields.Everything(), "1") + watcher, err := t.storage.(rest.Watcher).Watch(ctx, &api.ListOptions{ResourceVersion: "1"}) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -976,7 +977,8 @@ func (t *Tester) testWatchFields(obj runtime.Object, initWatchFn InitWatchFunc, for _, field := range fieldsPass { for _, action := range actions { - watcher, err := t.storage.(rest.Watcher).Watch(ctx, labels.Everything(), field.AsSelector(), "1") + options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"} + watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -999,7 +1001,8 @@ func (t *Tester) testWatchFields(obj runtime.Object, initWatchFn InitWatchFunc, for _, field := range fieldsFail { for _, action := range actions { - watcher, err := t.storage.(rest.Watcher).Watch(ctx, labels.Everything(), field.AsSelector(), "1") + options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"} + watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -1024,7 +1027,8 @@ func (t *Tester) testWatchLabels(obj runtime.Object, initWatchFn InitWatchFunc, for _, label := range labelsPass { for _, action := range actions { - watcher, err := t.storage.(rest.Watcher).Watch(ctx, label.AsSelector(), fields.Everything(), "1") + options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"} + watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -1047,7 +1051,8 @@ func (t *Tester) testWatchLabels(obj runtime.Object, initWatchFn InitWatchFunc, for _, label := range labelsFail { for _, action := range actions { - watcher, err := t.storage.(rest.Watcher).Watch(ctx, label.AsSelector(), fields.Everything(), "1") + options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"} + watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) if err != nil { t.Errorf("unexpected error: %v", err) } diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index dd5433e635a..a0a990a5ef0 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -307,13 +307,19 @@ type SimpleRESTStorage struct { injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error) } -func (storage *SimpleRESTStorage) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) { +func (storage *SimpleRESTStorage) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) { storage.checkContext(ctx) result := &apiservertesting.SimpleList{ Items: storage.list, } - storage.requestedLabelSelector = label - storage.requestedFieldSelector = field + storage.requestedLabelSelector = labels.Everything() + if options != nil && options.LabelSelector != nil { + storage.requestedLabelSelector = options.LabelSelector + } + storage.requestedFieldSelector = fields.Everything() + if options != nil && options.FieldSelector != nil { + storage.requestedFieldSelector = options.FieldSelector + } return result, storage.errors["list"] } @@ -410,11 +416,20 @@ func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (r } // Implement ResourceWatcher. -func (storage *SimpleRESTStorage) Watch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { +func (storage *SimpleRESTStorage) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { storage.checkContext(ctx) - storage.requestedLabelSelector = label - storage.requestedFieldSelector = field - storage.requestedResourceVersion = resourceVersion + storage.requestedLabelSelector = labels.Everything() + if options != nil && options.LabelSelector != nil { + storage.requestedLabelSelector = options.LabelSelector + } + storage.requestedFieldSelector = fields.Everything() + if options != nil && options.FieldSelector != nil { + storage.requestedFieldSelector = options.FieldSelector + } + storage.requestedResourceVersion = "" + if options != nil { + storage.requestedResourceVersion = options.ResourceVersion + } storage.requestedResourceNamespace = api.NamespaceValue(ctx) if err := storage.errors["watch"]; err != nil { return nil, err diff --git a/pkg/apiserver/resthandler.go b/pkg/apiserver/resthandler.go index 1af59a4a922..d9eaa916fd5 100644 --- a/pkg/apiserver/resthandler.go +++ b/pkg/apiserver/resthandler.go @@ -267,7 +267,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch } if (opts.Watch || forceWatch) && rw != nil { - watcher, err := rw.Watch(ctx, opts.LabelSelector, opts.FieldSelector, opts.ResourceVersion) + watcher, err := rw.Watch(ctx, &opts) if err != nil { errorJSON(err, scope.Codec, w) return @@ -284,7 +284,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch return } - result, err := r.List(ctx, opts.LabelSelector, opts.FieldSelector, &opts) + result, err := r.List(ctx, &opts) if err != nil { errorJSON(err, scope.Codec, w) return diff --git a/pkg/master/master.go b/pkg/master/master.go index 34008c7e586..a04ca42750d 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -42,9 +42,7 @@ import ( "k8s.io/kubernetes/pkg/auth/authorizer" "k8s.io/kubernetes/pkg/auth/handlers" client "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/healthz" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/master/ports" "k8s.io/kubernetes/pkg/registry/componentstatus" controlleretcd "k8s.io/kubernetes/pkg/registry/controller/etcd" @@ -935,7 +933,7 @@ func (m *Master) RemoveThirdPartyResource(path string) error { func (m *Master) removeAllThirdPartyResources(registry *thirdpartyresourcedataetcd.REST) error { ctx := api.NewDefaultContext() - existingData, err := registry.List(ctx, labels.Everything(), fields.Everything(), nil) + existingData, err := registry.List(ctx, nil) if err != nil { return err } @@ -1138,7 +1136,7 @@ func findExternalAddress(node *api.Node) (string, error) { } func (m *Master) getNodeAddresses() ([]string, error) { - nodes, err := m.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil) + nodes, err := m.nodeRegistry.ListNodes(api.NewDefaultContext(), nil) if err != nil { return nil, err } diff --git a/pkg/master/master_test.go b/pkg/master/master_test.go index 89a3f374ce4..6e7d95eea42 100644 --- a/pkg/master/master_test.go +++ b/pkg/master/master_test.go @@ -40,8 +40,6 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apiserver" client "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/registry/endpoint" "k8s.io/kubernetes/pkg/registry/namespace" "k8s.io/kubernetes/pkg/registry/registrytest" @@ -338,14 +336,14 @@ func TestGetNodeAddresses(t *testing.T) { master, _, assert := setUp(t) // Fail case (no addresses associated with nodes) - nodes, _ := master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil) + nodes, _ := master.nodeRegistry.ListNodes(api.NewDefaultContext(), nil) addrs, err := master.getNodeAddresses() assert.Error(err, "getNodeAddresses should have caused an error as there are no addresses.") assert.Equal([]string(nil), addrs) // Pass case with External type IP - nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil) + nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), nil) for index := range nodes.Items { nodes.Items[index].Status.Addresses = []api.NodeAddress{{Type: api.NodeExternalIP, Address: "127.0.0.1"}} } @@ -354,7 +352,7 @@ func TestGetNodeAddresses(t *testing.T) { assert.Equal([]string{"127.0.0.1", "127.0.0.1"}, addrs) // Pass case with LegacyHost type IP - nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil) + nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), nil) for index := range nodes.Items { nodes.Items[index].Status.Addresses = []api.NodeAddress{{Type: api.NodeLegacyHostIP, Address: "127.0.0.2"}} } diff --git a/pkg/master/thirdparty_controller.go b/pkg/master/thirdparty_controller.go index e29766d5c4d..177f9467eba 100644 --- a/pkg/master/thirdparty_controller.go +++ b/pkg/master/thirdparty_controller.go @@ -22,8 +22,6 @@ import ( "k8s.io/kubernetes/pkg/api" expapi "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" thirdpartyresourceetcd "k8s.io/kubernetes/pkg/registry/thirdpartyresource/etcd" "k8s.io/kubernetes/pkg/registry/thirdpartyresourcedata" "k8s.io/kubernetes/pkg/runtime" @@ -76,7 +74,7 @@ func (t *ThirdPartyController) SyncOneResource(rsrc *expapi.ThirdPartyResource) // Synchronize all resources with RESTful resources on the master func (t *ThirdPartyController) SyncResources() error { - list, err := t.thirdPartyResourceRegistry.List(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil) + list, err := t.thirdPartyResourceRegistry.List(api.NewDefaultContext(), nil) if err != nil { return err } diff --git a/pkg/registry/componentstatus/rest.go b/pkg/registry/componentstatus/rest.go index 90f99ed0c26..c4c14f26fce 100644 --- a/pkg/registry/componentstatus/rest.go +++ b/pkg/registry/componentstatus/rest.go @@ -22,8 +22,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/apiserver" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/probe" "k8s.io/kubernetes/pkg/runtime" ) @@ -51,7 +49,7 @@ func (rs *REST) NewList() runtime.Object { // Returns the list of component status. Note that the label and field are both ignored. // Note that this call doesn't support labels or selectors. -func (rs *REST) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) { +func (rs *REST) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) { servers := rs.GetServersToValidate() // TODO: This should be parallelized. diff --git a/pkg/registry/componentstatus/rest_test.go b/pkg/registry/componentstatus/rest_test.go index 32fd6a38131..abe0c3f89da 100644 --- a/pkg/registry/componentstatus/rest_test.go +++ b/pkg/registry/componentstatus/rest_test.go @@ -27,8 +27,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/apiserver" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/util" ) @@ -78,7 +76,7 @@ func createTestStatus(name string, status api.ConditionStatus, msg string, err s func TestList_NoError(t *testing.T) { r := NewTestREST(testResponse{code: 200, data: "ok"}) - got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything(), nil) + got, err := r.List(api.NewContext(), nil) if err != nil { t.Fatalf("Unexpected error: %v", err) } @@ -92,7 +90,7 @@ func TestList_NoError(t *testing.T) { func TestList_FailedCheck(t *testing.T) { r := NewTestREST(testResponse{code: 500, data: ""}) - got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything(), nil) + got, err := r.List(api.NewContext(), nil) if err != nil { t.Fatalf("Unexpected error: %v", err) } @@ -107,7 +105,7 @@ func TestList_FailedCheck(t *testing.T) { func TestList_UnknownError(t *testing.T) { r := NewTestREST(testResponse{code: 500, data: "", err: fmt.Errorf("fizzbuzz error")}) - got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything(), nil) + got, err := r.List(api.NewContext(), nil) if err != nil { t.Fatalf("Unexpected error: %v", err) } diff --git a/pkg/registry/controller/registry.go b/pkg/registry/controller/registry.go index de0be2d7a1b..12aa757405c 100644 --- a/pkg/registry/controller/registry.go +++ b/pkg/registry/controller/registry.go @@ -21,15 +21,13 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store ReplicationControllers. type Registry interface { - ListControllers(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ReplicationControllerList, error) - WatchControllers(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) + ListControllers(ctx api.Context, options *api.ListOptions) (*api.ReplicationControllerList, error) + WatchControllers(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error) CreateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error) UpdateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error) @@ -47,20 +45,19 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -// List obtains a list of ReplicationControllers that match selector. -func (s *storage) ListControllers(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ReplicationControllerList, error) { - if !field.Empty() { +func (s *storage) ListControllers(ctx api.Context, options *api.ListOptions) (*api.ReplicationControllerList, error) { + if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { return nil, fmt.Errorf("field selector not supported yet") } - obj, err := s.List(ctx, label, field, options) + obj, err := s.List(ctx, options) if err != nil { return nil, err } return obj.(*api.ReplicationControllerList), err } -func (s *storage) WatchControllers(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchControllers(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error) { diff --git a/pkg/registry/deployment/registry.go b/pkg/registry/deployment/registry.go index 018ee3bc52b..ec967e93d9c 100644 --- a/pkg/registry/deployment/registry.go +++ b/pkg/registry/deployment/registry.go @@ -22,13 +22,11 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" ) // Registry is an interface for things that know how to store Deployments. type Registry interface { - ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.DeploymentList, error) + ListDeployments(ctx api.Context, options *api.ListOptions) (*extensions.DeploymentList, error) GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error) CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) @@ -45,12 +43,11 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -// List obtains a list of Deployments that match selector. -func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.DeploymentList, error) { - if !field.Empty() { +func (s *storage) ListDeployments(ctx api.Context, options *api.ListOptions) (*extensions.DeploymentList, error) { + if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { return nil, fmt.Errorf("field selector not supported yet") } - obj, err := s.List(ctx, label, field, options) + obj, err := s.List(ctx, options) if err != nil { return nil, err } diff --git a/pkg/registry/endpoint/registry.go b/pkg/registry/endpoint/registry.go index c9607c5ab0a..a034852fb6d 100644 --- a/pkg/registry/endpoint/registry.go +++ b/pkg/registry/endpoint/registry.go @@ -19,16 +19,14 @@ package endpoint import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store endpoints. type Registry interface { - ListEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.EndpointsList, error) + ListEndpoints(ctx api.Context, options *api.ListOptions) (*api.EndpointsList, error) GetEndpoints(ctx api.Context, name string) (*api.Endpoints, error) - WatchEndpoints(ctx api.Context, labels labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) + WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) UpdateEndpoints(ctx api.Context, e *api.Endpoints) error DeleteEndpoints(ctx api.Context, name string) error } @@ -44,16 +42,16 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.EndpointsList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListEndpoints(ctx api.Context, options *api.ListOptions) (*api.EndpointsList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } return obj.(*api.EndpointsList), nil } -func (s *storage) WatchEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetEndpoints(ctx api.Context, name string) (*api.Endpoints, error) { diff --git a/pkg/registry/generic/etcd/etcd.go b/pkg/registry/generic/etcd/etcd.go index 2fde3f1059c..42c994fe42f 100644 --- a/pkg/registry/generic/etcd/etcd.go +++ b/pkg/registry/generic/etcd/etcd.go @@ -159,7 +159,15 @@ func (e *Etcd) NewList() runtime.Object { } // List returns a list of items matching labels and field -func (e *Etcd) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) { +func (e *Etcd) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) { + label := labels.Everything() + if options != nil && options.LabelSelector != nil { + label = options.LabelSelector + } + field := fields.Everything() + if options != nil && options.FieldSelector != nil { + field = options.FieldSelector + } return e.ListPredicate(ctx, e.PredicateFunc(label, field), options) } @@ -463,7 +471,19 @@ func (e *Etcd) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Object // WatchPredicate. If possible, you should customize PredicateFunc to produre a // matcher that matches by key. generic.SelectionPredicate does this for you // automatically. -func (e *Etcd) Watch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { +func (e *Etcd) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + label := labels.Everything() + if options != nil && options.LabelSelector != nil { + label = options.LabelSelector + } + field := fields.Everything() + if options != nil && options.FieldSelector != nil { + field = options.FieldSelector + } + resourceVersion := "" + if options != nil { + resourceVersion = options.ResourceVersion + } return e.WatchPredicate(ctx, e.PredicateFunc(label, field), resourceVersion) } diff --git a/pkg/registry/job/registry.go b/pkg/registry/job/registry.go deleted file mode 100644 index fc0da64e334..00000000000 --- a/pkg/registry/job/registry.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package job - -import ( - "fmt" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// Registry is an interface for things that know how to store Jobs. -type Registry interface { - // ListJobs obtains a list of Jobs having labels and fields which match selector. - ListJobs(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.JobList, error) - // WatchJobs watch for new/changed/deleted Jobs. - WatchJobs(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // GetJobs gets a specific Job. - GetJob(ctx api.Context, name string) (*extensions.Job, error) - // CreateJob creates a Job based on a specification. - CreateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error) - // UpdateJob updates an existing Job. - UpdateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error) - // DeleteJob deletes an existing Job. - DeleteJob(ctx api.Context, name string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.JobList, error) { - if !field.Empty() { - return nil, fmt.Errorf("field selector not supported yet") - } - obj, err := s.List(ctx, label, field, options) - if err != nil { - return nil, err - } - return obj.(*extensions.JobList), err -} - -func (s *storage) WatchJobs(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) -} - -func (s *storage) GetJob(ctx api.Context, name string) (*extensions.Job, error) { - obj, err := s.Get(ctx, name) - if err != nil { - return nil, err - } - return obj.(*extensions.Job), nil -} - -func (s *storage) CreateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error) { - obj, err := s.Create(ctx, job) - if err != nil { - return nil, err - } - return obj.(*extensions.Job), nil -} - -func (s *storage) UpdateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error) { - obj, _, err := s.Update(ctx, job) - if err != nil { - return nil, err - } - return obj.(*extensions.Job), nil -} - -func (s *storage) DeleteJob(ctx api.Context, name string) error { - _, err := s.Delete(ctx, name, nil) - return err -} diff --git a/pkg/registry/namespace/registry.go b/pkg/registry/namespace/registry.go index a7801a58fc1..33b50d32e67 100644 --- a/pkg/registry/namespace/registry.go +++ b/pkg/registry/namespace/registry.go @@ -19,24 +19,16 @@ package namespace import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store Namespace objects. type Registry interface { - // ListNamespaces obtains a list of namespaces having labels which match selector. - ListNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NamespaceList, error) - // Watch for new/changed/deleted namespaces - WatchNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific namespace + ListNamespaces(ctx api.Context, options *api.ListOptions) (*api.NamespaceList, error) + WatchNamespaces(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetNamespace(ctx api.Context, namespaceID string) (*api.Namespace, error) - // Create a namespace based on a specification. CreateNamespace(ctx api.Context, namespace *api.Namespace) error - // Update an existing namespace UpdateNamespace(ctx api.Context, namespace *api.Namespace) error - // Delete an existing namespace DeleteNamespace(ctx api.Context, namespaceID string) error } @@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NamespaceList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListNamespaces(ctx api.Context, options *api.ListOptions) (*api.NamespaceList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } return obj.(*api.NamespaceList), nil } -func (s *storage) WatchNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchNamespaces(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetNamespace(ctx api.Context, namespaceName string) (*api.Namespace, error) { diff --git a/pkg/registry/node/registry.go b/pkg/registry/node/registry.go index 5f9159a4a32..3d6f3bf07ea 100644 --- a/pkg/registry/node/registry.go +++ b/pkg/registry/node/registry.go @@ -19,19 +19,17 @@ package node import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store node. type Registry interface { - ListNodes(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NodeList, error) + ListNodes(ctx api.Context, options *api.ListOptions) (*api.NodeList, error) CreateNode(ctx api.Context, node *api.Node) error UpdateNode(ctx api.Context, node *api.Node) error GetNode(ctx api.Context, nodeID string) (*api.Node, error) DeleteNode(ctx api.Context, nodeID string) error - WatchNodes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) + WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -45,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NodeList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListNodes(ctx api.Context, options *api.ListOptions) (*api.NodeList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } @@ -64,8 +62,8 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error { return err } -func (s *storage) WatchNodes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetNode(ctx api.Context, name string) (*api.Node, error) { diff --git a/pkg/registry/registrytest/endpoint.go b/pkg/registry/registrytest/endpoint.go index 98adc9007e5..c02adb10bbb 100644 --- a/pkg/registry/registrytest/endpoint.go +++ b/pkg/registry/registrytest/endpoint.go @@ -22,8 +22,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/errors" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) @@ -36,7 +34,7 @@ type EndpointRegistry struct { lock sync.Mutex } -func (e *EndpointRegistry) ListEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.EndpointsList, error) { +func (e *EndpointRegistry) ListEndpoints(ctx api.Context, options *api.ListOptions) (*api.EndpointsList, error) { // TODO: support namespaces in this mock e.lock.Lock() defer e.lock.Unlock() @@ -61,7 +59,7 @@ func (e *EndpointRegistry) GetEndpoints(ctx api.Context, name string) (*api.Endp return nil, errors.NewNotFound("Endpoints", name) } -func (e *EndpointRegistry) WatchEndpoints(ctx api.Context, labels labels.Selector, fields fields.Selector, resourceVersion string) (watch.Interface, error) { +func (e *EndpointRegistry) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { return nil, fmt.Errorf("unimplemented!") } diff --git a/pkg/registry/registrytest/node.go b/pkg/registry/registrytest/node.go index 00c29a0ff39..aef59d6a2aa 100644 --- a/pkg/registry/registrytest/node.go +++ b/pkg/registry/registrytest/node.go @@ -21,8 +21,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/errors" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) @@ -59,7 +57,7 @@ func (r *NodeRegistry) SetError(err error) { r.Err = err } -func (r *NodeRegistry) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NodeList, error) { +func (r *NodeRegistry) ListNodes(ctx api.Context, options *api.ListOptions) (*api.NodeList, error) { r.Lock() defer r.Unlock() return &r.Nodes, r.Err @@ -112,6 +110,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error { return r.Err } -func (r *NodeRegistry) WatchNodes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { +func (r *NodeRegistry) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { return nil, r.Err } diff --git a/pkg/registry/registrytest/service.go b/pkg/registry/registrytest/service.go index 7b63702c8fb..751ef88998d 100644 --- a/pkg/registry/registrytest/service.go +++ b/pkg/registry/registrytest/service.go @@ -20,8 +20,6 @@ import ( "sync" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) @@ -46,7 +44,7 @@ func (r *ServiceRegistry) SetError(err error) { r.Err = err } -func (r *ServiceRegistry) ListServices(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceList, error) { +func (r *ServiceRegistry) ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error) { r.mu.Lock() defer r.mu.Unlock() @@ -106,7 +104,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api return svc, r.Err } -func (r *ServiceRegistry) WatchServices(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { +func (r *ServiceRegistry) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { r.mu.Lock() defer r.mu.Unlock() diff --git a/pkg/registry/secret/registry.go b/pkg/registry/secret/registry.go index 98d19e2a650..ef989f0067b 100644 --- a/pkg/registry/secret/registry.go +++ b/pkg/registry/secret/registry.go @@ -19,24 +19,16 @@ package secret import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store Secret objects. type Registry interface { - // ListSecrets obtains a list of Secrets having labels which match selector. - ListSecrets(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.SecretList, error) - // Watch for new/changed/deleted secrets - WatchSecrets(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific Secret + ListSecrets(ctx api.Context, options *api.ListOptions) (*api.SecretList, error) + WatchSecrets(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetSecret(ctx api.Context, name string) (*api.Secret, error) - // Create a Secret based on a specification. CreateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error) - // Update an existing Secret UpdateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error) - // Delete an existing Secret DeleteSecret(ctx api.Context, name string) error } @@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListSecrets(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.SecretList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListSecrets(ctx api.Context, options *api.ListOptions) (*api.SecretList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } return obj.(*api.SecretList), nil } -func (s *storage) WatchSecrets(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchSecrets(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetSecret(ctx api.Context, name string) (*api.Secret, error) { diff --git a/pkg/registry/service/ipallocator/controller/repair.go b/pkg/registry/service/ipallocator/controller/repair.go index 9709abefd0f..cc95a576238 100644 --- a/pkg/registry/service/ipallocator/controller/repair.go +++ b/pkg/registry/service/ipallocator/controller/repair.go @@ -22,8 +22,6 @@ import ( "time" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service/ipallocator" "k8s.io/kubernetes/pkg/util" @@ -95,7 +93,7 @@ func (c *Repair) RunOnce() error { ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll) options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion} - list, err := c.registry.ListServices(ctx, labels.Everything(), fields.Everything(), options) + list, err := c.registry.ListServices(ctx, options) if err != nil { return fmt.Errorf("unable to refresh the service IP block: %v", err) } diff --git a/pkg/registry/service/portallocator/controller/repair.go b/pkg/registry/service/portallocator/controller/repair.go index 6e3840372db..c388a8dc955 100644 --- a/pkg/registry/service/portallocator/controller/repair.go +++ b/pkg/registry/service/portallocator/controller/repair.go @@ -21,8 +21,6 @@ import ( "time" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service/portallocator" "k8s.io/kubernetes/pkg/util" @@ -82,7 +80,7 @@ func (c *Repair) RunOnce() error { ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll) options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion} - list, err := c.registry.ListServices(ctx, labels.Everything(), fields.Everything(), options) + list, err := c.registry.ListServices(ctx, options) if err != nil { return fmt.Errorf("unable to refresh the port block: %v", err) } diff --git a/pkg/registry/service/registry.go b/pkg/registry/service/registry.go index 53f08e018ea..154dcb9d192 100644 --- a/pkg/registry/service/registry.go +++ b/pkg/registry/service/registry.go @@ -19,19 +19,17 @@ package service import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store services. type Registry interface { - ListServices(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceList, error) + ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error) CreateService(ctx api.Context, svc *api.Service) (*api.Service, error) GetService(ctx api.Context, name string) (*api.Service, error) DeleteService(ctx api.Context, name string) error UpdateService(ctx api.Context, svc *api.Service) (*api.Service, error) - WatchServices(ctx api.Context, labels labels.Selector, fields fields.Selector, resourceVersion string) (watch.Interface, error) + WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -45,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListServices(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } @@ -82,8 +80,8 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service return obj.(*api.Service), nil } -func (s *storage) WatchServices(ctx api.Context, labels labels.Selector, fields fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, labels, fields, resourceVersion) +func (s *storage) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } // TODO: Move to a general location (as other components may need allocation in future; it's not service specific) diff --git a/pkg/registry/service/rest.go b/pkg/registry/service/rest.go index 218d4dd4aab..46b55dd6266 100644 --- a/pkg/registry/service/rest.go +++ b/pkg/registry/service/rest.go @@ -30,8 +30,6 @@ import ( "k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/validation" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/registry/endpoint" "k8s.io/kubernetes/pkg/registry/service/ipallocator" "k8s.io/kubernetes/pkg/registry/service/portallocator" @@ -173,14 +171,14 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { return rs.registry.GetService(ctx, id) } -func (rs *REST) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) { - return rs.registry.ListServices(ctx, label, field, options) +func (rs *REST) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) { + return rs.registry.ListServices(ctx, options) } // Watch returns Services events via a watch.Interface. // It implements rest.Watcher. -func (rs *REST) Watch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return rs.registry.WatchServices(ctx, label, field, resourceVersion) +func (rs *REST) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return rs.registry.WatchServices(ctx, options) } func (*REST) New() runtime.Object { diff --git a/pkg/registry/service/rest_test.go b/pkg/registry/service/rest_test.go index 4e336541163..4f92477a011 100644 --- a/pkg/registry/service/rest_test.go +++ b/pkg/registry/service/rest_test.go @@ -24,8 +24,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/registry/registrytest" "k8s.io/kubernetes/pkg/registry/service/ipallocator" "k8s.io/kubernetes/pkg/registry/service/portallocator" @@ -543,7 +541,7 @@ func TestServiceRegistryList(t *testing.T) { }, }) registry.List.ResourceVersion = "1" - s, _ := storage.List(ctx, labels.Everything(), fields.Everything(), nil) + s, _ := storage.List(ctx, nil) sl := s.(*api.ServiceList) if len(sl.Items) != 2 { t.Fatalf("Expected 2 services, but got %v", len(sl.Items)) diff --git a/pkg/registry/serviceaccount/registry.go b/pkg/registry/serviceaccount/registry.go index e62928b00ec..4dad500bc61 100644 --- a/pkg/registry/serviceaccount/registry.go +++ b/pkg/registry/serviceaccount/registry.go @@ -19,24 +19,16 @@ package serviceaccount import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store ServiceAccount objects. type Registry interface { - // ListServiceAccounts obtains a list of ServiceAccounts having labels which match selector. - ListServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceAccountList, error) - // Watch for new/changed/deleted service accounts - WatchServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific ServiceAccount + ListServiceAccounts(ctx api.Context, options *api.ListOptions) (*api.ServiceAccountList, error) + WatchServiceAccounts(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetServiceAccount(ctx api.Context, name string) (*api.ServiceAccount, error) - // Create a ServiceAccount based on a specification. CreateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error - // Update an existing ServiceAccount UpdateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error - // Delete an existing ServiceAccount DeleteServiceAccount(ctx api.Context, name string) error } @@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceAccountList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListServiceAccounts(ctx api.Context, options *api.ListOptions) (*api.ServiceAccountList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } return obj.(*api.ServiceAccountList), nil } -func (s *storage) WatchServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchServiceAccounts(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetServiceAccount(ctx api.Context, name string) (*api.ServiceAccount, error) { diff --git a/pkg/registry/thirdpartyresourcedata/registry.go b/pkg/registry/thirdpartyresourcedata/registry.go index 32346c7a2a0..5e560dede2d 100644 --- a/pkg/registry/thirdpartyresourcedata/registry.go +++ b/pkg/registry/thirdpartyresourcedata/registry.go @@ -20,24 +20,16 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects. type Registry interface { - // ListThirdPartyResourceData obtains a list of ThirdPartyResourceData having labels which match selector. - ListThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error) - // Watch for new/changed/deleted ThirdPartyResourceData - WatchThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific ThirdPartyResourceData + ListThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error) + WatchThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error) - // Create a ThirdPartyResourceData based on a specification. CreateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error) - // Update an existing ThirdPartyResourceData UpdateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error) - // Delete an existing ThirdPartyResourceData DeleteThirdPartyResourceData(ctx api.Context, name string) error } @@ -52,16 +44,16 @@ func NewRegistry(s rest.StandardStorage) Registry { return &storage{s} } -func (s *storage) ListThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error) { - obj, err := s.List(ctx, label, field, options) +func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error) { + obj, err := s.List(ctx, options) if err != nil { return nil, err } return obj.(*extensions.ThirdPartyResourceDataList), nil } -func (s *storage) WatchThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) +func (s *storage) WatchThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (watch.Interface, error) { + return s.Watch(ctx, options) } func (s *storage) GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error) {