Pass resource version to storage List operation.
This commit is contained in:
parent
a094a6e3de
commit
aa30e38183
@ -61,8 +61,9 @@ type Lister interface {
|
|||||||
// NewList returns an empty object that can be used with the List call.
|
// NewList returns an empty object that can be used with the List call.
|
||||||
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
|
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
|
||||||
NewList() runtime.Object
|
NewList() runtime.Object
|
||||||
// List selects resources in the storage which match to the selector.
|
// List selects resources in the storage which match to the selector. 'options' can be nil.
|
||||||
List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error)
|
// TODO: Move 'label' and 'field' to 'options'.
|
||||||
|
List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter is an object that can retrieve a named RESTful resource.
|
// Getter is an object that can retrieve a named RESTful resource.
|
||||||
@ -183,6 +184,7 @@ type Watcher interface {
|
|||||||
// are supported; an error should be returned if 'field' tries to select on a field that
|
// 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
|
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
|
||||||
// particular version.
|
// 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, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ func (t *Tester) testListError() {
|
|||||||
|
|
||||||
storageError := fmt.Errorf("test error")
|
storageError := fmt.Errorf("test error")
|
||||||
t.withStorageError(storageError, func() {
|
t.withStorageError(storageError, func() {
|
||||||
_, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything())
|
_, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything(), nil)
|
||||||
if err != storageError {
|
if err != storageError {
|
||||||
t.Errorf("unexpected error: %v", err)
|
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})
|
existing := assignFn([]runtime.Object{foo1, foo2})
|
||||||
|
|
||||||
listObj, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything())
|
listObj, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
|
|||||||
filtered := []runtime.Object{existing[1]}
|
filtered := []runtime.Object{existing[1]}
|
||||||
|
|
||||||
selector := labels.SelectorFromSet(labels.Set(testLabels))
|
selector := labels.SelectorFromSet(labels.Set(testLabels))
|
||||||
listObj, err := t.storage.(rest.Lister).List(ctx, selector, fields.Everything())
|
listObj, err := t.storage.(rest.Lister).List(ctx, selector, fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -924,7 +924,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) {
|
|||||||
setRVFn(uint64(123))
|
setRVFn(uint64(123))
|
||||||
_ = assignFn([]runtime.Object{})
|
_ = assignFn([]runtime.Object{})
|
||||||
|
|
||||||
listObj, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything())
|
listObj, err := t.storage.(rest.Lister).List(ctx, labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ type SimpleRESTStorage struct {
|
|||||||
injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error)
|
injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
result := &apiservertesting.SimpleList{
|
result := &apiservertesting.SimpleList{
|
||||||
Items: storage.list,
|
Items: storage.list,
|
||||||
|
@ -284,7 +284,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := r.List(ctx, opts.LabelSelector, opts.FieldSelector)
|
result, err := r.List(ctx, opts.LabelSelector, opts.FieldSelector, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorJSON(err, scope.Codec, w)
|
errorJSON(err, scope.Codec, w)
|
||||||
return
|
return
|
||||||
|
@ -935,7 +935,7 @@ func (m *Master) RemoveThirdPartyResource(path string) error {
|
|||||||
|
|
||||||
func (m *Master) removeAllThirdPartyResources(registry *thirdpartyresourcedataetcd.REST) error {
|
func (m *Master) removeAllThirdPartyResources(registry *thirdpartyresourcedataetcd.REST) error {
|
||||||
ctx := api.NewDefaultContext()
|
ctx := api.NewDefaultContext()
|
||||||
existingData, err := registry.List(ctx, labels.Everything(), fields.Everything())
|
existingData, err := registry.List(ctx, labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1137,7 +1137,7 @@ func findExternalAddress(node *api.Node) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Master) getNodeAddresses() ([]string, error) {
|
func (m *Master) getNodeAddresses() ([]string, error) {
|
||||||
nodes, err := m.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
nodes, err := m.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -338,14 +338,14 @@ func TestGetNodeAddresses(t *testing.T) {
|
|||||||
master, _, assert := setUp(t)
|
master, _, assert := setUp(t)
|
||||||
|
|
||||||
// Fail case (no addresses associated with nodes)
|
// Fail case (no addresses associated with nodes)
|
||||||
nodes, _ := master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
nodes, _ := master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
addrs, err := master.getNodeAddresses()
|
addrs, err := master.getNodeAddresses()
|
||||||
|
|
||||||
assert.Error(err, "getNodeAddresses should have caused an error as there are no addresses.")
|
assert.Error(err, "getNodeAddresses should have caused an error as there are no addresses.")
|
||||||
assert.Equal([]string(nil), addrs)
|
assert.Equal([]string(nil), addrs)
|
||||||
|
|
||||||
// Pass case with External type IP
|
// Pass case with External type IP
|
||||||
nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
for index := range nodes.Items {
|
for index := range nodes.Items {
|
||||||
nodes.Items[index].Status.Addresses = []api.NodeAddress{{Type: api.NodeExternalIP, Address: "127.0.0.1"}}
|
nodes.Items[index].Status.Addresses = []api.NodeAddress{{Type: api.NodeExternalIP, Address: "127.0.0.1"}}
|
||||||
}
|
}
|
||||||
@ -354,7 +354,7 @@ func TestGetNodeAddresses(t *testing.T) {
|
|||||||
assert.Equal([]string{"127.0.0.1", "127.0.0.1"}, addrs)
|
assert.Equal([]string{"127.0.0.1", "127.0.0.1"}, addrs)
|
||||||
|
|
||||||
// Pass case with LegacyHost type IP
|
// Pass case with LegacyHost type IP
|
||||||
nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
nodes, _ = master.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
for index := range nodes.Items {
|
for index := range nodes.Items {
|
||||||
nodes.Items[index].Status.Addresses = []api.NodeAddress{{Type: api.NodeLegacyHostIP, Address: "127.0.0.2"}}
|
nodes.Items[index].Status.Addresses = []api.NodeAddress{{Type: api.NodeLegacyHostIP, Address: "127.0.0.2"}}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ func (t *ThirdPartyController) SyncOneResource(rsrc *expapi.ThirdPartyResource)
|
|||||||
|
|
||||||
// Synchronize all resources with RESTful resources on the master
|
// Synchronize all resources with RESTful resources on the master
|
||||||
func (t *ThirdPartyController) SyncResources() error {
|
func (t *ThirdPartyController) SyncResources() error {
|
||||||
list, err := t.thirdPartyResourceRegistry.List(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
list, err := t.thirdPartyResourceRegistry.List(api.NewDefaultContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func (rs *REST) NewList() runtime.Object {
|
|||||||
|
|
||||||
// Returns the list of component status. Note that the label and field are both ignored.
|
// 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.
|
// Note that this call doesn't support labels or selectors.
|
||||||
func (rs *REST) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
|
func (rs *REST) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) {
|
||||||
servers := rs.GetServersToValidate()
|
servers := rs.GetServersToValidate()
|
||||||
|
|
||||||
// TODO: This should be parallelized.
|
// TODO: This should be parallelized.
|
||||||
|
@ -78,7 +78,7 @@ func createTestStatus(name string, status api.ConditionStatus, msg string, err s
|
|||||||
|
|
||||||
func TestList_NoError(t *testing.T) {
|
func TestList_NoError(t *testing.T) {
|
||||||
r := NewTestREST(testResponse{code: 200, data: "ok"})
|
r := NewTestREST(testResponse{code: 200, data: "ok"})
|
||||||
got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything())
|
got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ func TestList_NoError(t *testing.T) {
|
|||||||
|
|
||||||
func TestList_FailedCheck(t *testing.T) {
|
func TestList_FailedCheck(t *testing.T) {
|
||||||
r := NewTestREST(testResponse{code: 500, data: ""})
|
r := NewTestREST(testResponse{code: 500, data: ""})
|
||||||
got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything())
|
got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ func TestList_FailedCheck(t *testing.T) {
|
|||||||
|
|
||||||
func TestList_UnknownError(t *testing.T) {
|
func TestList_UnknownError(t *testing.T) {
|
||||||
r := NewTestREST(testResponse{code: 500, data: "", err: fmt.Errorf("fizzbuzz error")})
|
r := NewTestREST(testResponse{code: 500, data: "", err: fmt.Errorf("fizzbuzz error")})
|
||||||
got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything())
|
got, err := r.List(api.NewContext(), labels.Everything(), fields.Everything(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
// Registry is an interface for things that know how to store ReplicationControllers.
|
// Registry is an interface for things that know how to store ReplicationControllers.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
ListControllers(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ReplicationControllerList, error)
|
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)
|
WatchControllers(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error)
|
GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error)
|
||||||
CreateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error)
|
CreateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error)
|
||||||
@ -48,11 +48,11 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List obtains a list of ReplicationControllers that match selector.
|
// List obtains a list of ReplicationControllers that match selector.
|
||||||
func (s *storage) ListControllers(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ReplicationControllerList, error) {
|
func (s *storage) ListControllers(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ReplicationControllerList, error) {
|
||||||
if !field.Empty() {
|
if !field.Empty() {
|
||||||
return nil, fmt.Errorf("field selector not supported yet")
|
return nil, fmt.Errorf("field selector not supported yet")
|
||||||
}
|
}
|
||||||
obj, err := s.List(ctx, label, field)
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
// Registry is an interface for things that know how to store Deployments.
|
// Registry is an interface for things that know how to store Deployments.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.DeploymentList, error)
|
ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.DeploymentList, error)
|
||||||
GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error)
|
GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error)
|
||||||
CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
||||||
UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
||||||
@ -46,11 +46,11 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List obtains a list of Deployments that match selector.
|
// List obtains a list of Deployments that match selector.
|
||||||
func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.DeploymentList, error) {
|
func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.DeploymentList, error) {
|
||||||
if !field.Empty() {
|
if !field.Empty() {
|
||||||
return nil, fmt.Errorf("field selector not supported yet")
|
return nil, fmt.Errorf("field selector not supported yet")
|
||||||
}
|
}
|
||||||
obj, err := s.List(ctx, label, field)
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// Registry is an interface for things that know how to store endpoints.
|
// Registry is an interface for things that know how to store endpoints.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
ListEndpoints(ctx api.Context) (*api.EndpointsList, error)
|
ListEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.EndpointsList, error)
|
||||||
GetEndpoints(ctx api.Context, name string) (*api.Endpoints, 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, labels labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
UpdateEndpoints(ctx api.Context, e *api.Endpoints) error
|
UpdateEndpoints(ctx api.Context, e *api.Endpoints) error
|
||||||
@ -44,8 +44,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListEndpoints(ctx api.Context) (*api.EndpointsList, error) {
|
func (s *storage) ListEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.EndpointsList, error) {
|
||||||
obj, err := s.List(ctx, labels.Everything(), fields.Everything())
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -159,12 +159,12 @@ func (e *Etcd) NewList() runtime.Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List returns a list of items matching labels and field
|
// List returns a list of items matching labels and field
|
||||||
func (e *Etcd) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
|
func (e *Etcd) List(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (runtime.Object, error) {
|
||||||
return e.ListPredicate(ctx, e.PredicateFunc(label, field))
|
return e.ListPredicate(ctx, e.PredicateFunc(label, field), options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPredicate returns a list of all the items matching m.
|
// ListPredicate returns a list of all the items matching m.
|
||||||
func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object, error) {
|
func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *api.ListOptions) (runtime.Object, error) {
|
||||||
list := e.NewListFunc()
|
list := e.NewListFunc()
|
||||||
trace := util.NewTrace("List " + reflect.TypeOf(list).String())
|
trace := util.NewTrace("List " + reflect.TypeOf(list).String())
|
||||||
filterFunc := e.filterAndDecorateFunction(m)
|
filterFunc := e.filterAndDecorateFunction(m)
|
||||||
@ -183,7 +183,14 @@ func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object
|
|||||||
}
|
}
|
||||||
|
|
||||||
trace.Step("About to list directory")
|
trace.Step("About to list directory")
|
||||||
err := e.Storage.List(ctx, e.KeyRootFunc(ctx), filterFunc, list)
|
if options == nil {
|
||||||
|
options = &api.ListOptions{ResourceVersion: "0"}
|
||||||
|
}
|
||||||
|
version, err := storage.ParseWatchResourceVersion(options.ResourceVersion, e.EndpointName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = e.Storage.List(ctx, e.KeyRootFunc(ctx), version, filterFunc, list)
|
||||||
trace.Step("List extracted")
|
trace.Step("List extracted")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -242,7 +242,7 @@ func TestEtcdList(t *testing.T) {
|
|||||||
key = etcdtest.AddPrefix(key)
|
key = etcdtest.AddPrefix(key)
|
||||||
fakeClient.Data[key] = item.in
|
fakeClient.Data[key] = item.in
|
||||||
}
|
}
|
||||||
list, err := registry.ListPredicate(ctx, item.m)
|
list, err := registry.ListPredicate(ctx, item.m, nil)
|
||||||
if e, a := item.succeed, err == nil; e != a {
|
if e, a := item.succeed, err == nil; e != a {
|
||||||
t.Errorf("%v: expected %v, got %v: %v", name, e, a, err)
|
t.Errorf("%v: expected %v, got %v: %v", name, e, a, err)
|
||||||
continue
|
continue
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
// Registry is an interface for things that know how to store Jobs.
|
// Registry is an interface for things that know how to store Jobs.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// ListJobs obtains a list of Jobs having labels and fields which match selector.
|
// ListJobs obtains a list of Jobs having labels and fields which match selector.
|
||||||
ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.JobList, error)
|
ListJobs(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.JobList, error)
|
||||||
// WatchJobs watch for new/changed/deleted Jobs.
|
// WatchJobs watch for new/changed/deleted Jobs.
|
||||||
WatchJobs(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
WatchJobs(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
// GetJobs gets a specific Job.
|
// GetJobs gets a specific Job.
|
||||||
@ -54,11 +54,11 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.JobList, error) {
|
func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.JobList, error) {
|
||||||
if !field.Empty() {
|
if !field.Empty() {
|
||||||
return nil, fmt.Errorf("field selector not supported yet")
|
return nil, fmt.Errorf("field selector not supported yet")
|
||||||
}
|
}
|
||||||
obj, err := s.List(ctx, label, field)
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
// Registry is an interface implemented by things that know how to store Namespace objects.
|
// Registry is an interface implemented by things that know how to store Namespace objects.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// ListNamespaces obtains a list of namespaces having labels which match selector.
|
// ListNamespaces obtains a list of namespaces having labels which match selector.
|
||||||
ListNamespaces(ctx api.Context, selector labels.Selector) (*api.NamespaceList, error)
|
ListNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NamespaceList, error)
|
||||||
// Watch for new/changed/deleted namespaces
|
// Watch for new/changed/deleted namespaces
|
||||||
WatchNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
WatchNamespaces(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
// Get a specific namespace
|
// Get a specific namespace
|
||||||
@ -51,8 +51,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListNamespaces(ctx api.Context, label labels.Selector) (*api.NamespaceList, error) {
|
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, fields.Everything())
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// Registry is an interface for things that know how to store node.
|
// Registry is an interface for things that know how to store node.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
ListNodes(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error)
|
ListNodes(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NodeList, error)
|
||||||
CreateNode(ctx api.Context, node *api.Node) error
|
CreateNode(ctx api.Context, node *api.Node) error
|
||||||
UpdateNode(ctx api.Context, node *api.Node) error
|
UpdateNode(ctx api.Context, node *api.Node) error
|
||||||
GetNode(ctx api.Context, nodeID string) (*api.Node, error)
|
GetNode(ctx api.Context, nodeID string) (*api.Node, error)
|
||||||
@ -45,8 +45,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
|
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)
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ type EndpointRegistry struct {
|
|||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EndpointRegistry) ListEndpoints(ctx api.Context) (*api.EndpointsList, error) {
|
func (e *EndpointRegistry) ListEndpoints(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.EndpointsList, error) {
|
||||||
// TODO: support namespaces in this mock
|
// TODO: support namespaces in this mock
|
||||||
e.lock.Lock()
|
e.lock.Lock()
|
||||||
defer e.lock.Unlock()
|
defer e.lock.Unlock()
|
||||||
|
@ -59,7 +59,7 @@ func (r *NodeRegistry) SetError(err error) {
|
|||||||
r.Err = err
|
r.Err = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *NodeRegistry) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
|
func (r *NodeRegistry) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.NodeList, error) {
|
||||||
r.Lock()
|
r.Lock()
|
||||||
defer r.Unlock()
|
defer r.Unlock()
|
||||||
return &r.Nodes, r.Err
|
return &r.Nodes, r.Err
|
||||||
|
@ -46,7 +46,7 @@ func (r *ServiceRegistry) SetError(err error) {
|
|||||||
r.Err = err
|
r.Err = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ServiceRegistry) ListServices(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ServiceList, error) {
|
func (r *ServiceRegistry) ListServices(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceList, error) {
|
||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
defer r.mu.Unlock()
|
defer r.mu.Unlock()
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
// Registry is an interface implemented by things that know how to store Secret objects.
|
// Registry is an interface implemented by things that know how to store Secret objects.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// ListSecrets obtains a list of Secrets having labels which match selector.
|
// ListSecrets obtains a list of Secrets having labels which match selector.
|
||||||
ListSecrets(ctx api.Context, selector labels.Selector) (*api.SecretList, error)
|
ListSecrets(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.SecretList, error)
|
||||||
// Watch for new/changed/deleted secrets
|
// Watch for new/changed/deleted secrets
|
||||||
WatchSecrets(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
WatchSecrets(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
// Get a specific Secret
|
// Get a specific Secret
|
||||||
@ -51,8 +51,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListSecrets(ctx api.Context, label labels.Selector) (*api.SecretList, error) {
|
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, fields.Everything())
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,8 @@ func (c *Repair) RunOnce() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
|
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
|
||||||
list, err := c.registry.ListServices(ctx, labels.Everything(), fields.Everything())
|
options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
|
||||||
|
list, err := c.registry.ListServices(ctx, labels.Everything(), fields.Everything(), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to refresh the service IP block: %v", err)
|
return fmt.Errorf("unable to refresh the service IP block: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,8 @@ func (c *Repair) RunOnce() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
|
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
|
||||||
list, err := c.registry.ListServices(ctx, labels.Everything(), fields.Everything())
|
options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
|
||||||
|
list, err := c.registry.ListServices(ctx, labels.Everything(), fields.Everything(), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to refresh the port block: %v", err)
|
return fmt.Errorf("unable to refresh the port block: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// Registry is an interface for things that know how to store services.
|
// Registry is an interface for things that know how to store services.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
ListServices(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ServiceList, error)
|
ListServices(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceList, error)
|
||||||
CreateService(ctx api.Context, svc *api.Service) (*api.Service, error)
|
CreateService(ctx api.Context, svc *api.Service) (*api.Service, error)
|
||||||
GetService(ctx api.Context, name string) (*api.Service, error)
|
GetService(ctx api.Context, name string) (*api.Service, error)
|
||||||
DeleteService(ctx api.Context, name string) error
|
DeleteService(ctx api.Context, name string) error
|
||||||
@ -45,8 +45,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListServices(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ServiceList, error) {
|
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)
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,8 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
|
|||||||
return rs.registry.GetService(ctx, id)
|
return rs.registry.GetService(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *REST) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
|
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)
|
return rs.registry.ListServices(ctx, label, field, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch returns Services events via a watch.Interface.
|
// Watch returns Services events via a watch.Interface.
|
||||||
|
@ -543,7 +543,7 @@ func TestServiceRegistryList(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
registry.List.ResourceVersion = "1"
|
registry.List.ResourceVersion = "1"
|
||||||
s, _ := storage.List(ctx, labels.Everything(), fields.Everything())
|
s, _ := storage.List(ctx, labels.Everything(), fields.Everything(), nil)
|
||||||
sl := s.(*api.ServiceList)
|
sl := s.(*api.ServiceList)
|
||||||
if len(sl.Items) != 2 {
|
if len(sl.Items) != 2 {
|
||||||
t.Fatalf("Expected 2 services, but got %v", len(sl.Items))
|
t.Fatalf("Expected 2 services, but got %v", len(sl.Items))
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
// Registry is an interface implemented by things that know how to store ServiceAccount objects.
|
// Registry is an interface implemented by things that know how to store ServiceAccount objects.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// ListServiceAccounts obtains a list of ServiceAccounts having labels which match selector.
|
// ListServiceAccounts obtains a list of ServiceAccounts having labels which match selector.
|
||||||
ListServiceAccounts(ctx api.Context, selector labels.Selector) (*api.ServiceAccountList, error)
|
ListServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*api.ServiceAccountList, error)
|
||||||
// Watch for new/changed/deleted service accounts
|
// Watch for new/changed/deleted service accounts
|
||||||
WatchServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
WatchServiceAccounts(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
// Get a specific ServiceAccount
|
// Get a specific ServiceAccount
|
||||||
@ -51,8 +51,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListServiceAccounts(ctx api.Context, label labels.Selector) (*api.ServiceAccountList, error) {
|
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, fields.Everything())
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
|
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// ListThirdPartyResourceData obtains a list of ThirdPartyResourceData having labels which match selector.
|
// ListThirdPartyResourceData obtains a list of ThirdPartyResourceData having labels which match selector.
|
||||||
ListThirdPartyResourceData(ctx api.Context, selector labels.Selector) (*extensions.ThirdPartyResourceDataList, error)
|
ListThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error)
|
||||||
// Watch for new/changed/deleted ThirdPartyResourceData
|
// Watch for new/changed/deleted ThirdPartyResourceData
|
||||||
WatchThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
WatchThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
// Get a specific ThirdPartyResourceData
|
// Get a specific ThirdPartyResourceData
|
||||||
@ -52,8 +52,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListThirdPartyResourceData(ctx api.Context, label labels.Selector) (*extensions.ThirdPartyResourceDataList, error) {
|
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, fields.Everything())
|
obj, err := s.List(ctx, label, field, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -219,8 +219,8 @@ func (c *Cacher) GetToList(ctx context.Context, key string, filter FilterFunc, l
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements storage.Interface.
|
// Implements storage.Interface.
|
||||||
func (c *Cacher) List(ctx context.Context, key string, filter FilterFunc, listObj runtime.Object) error {
|
func (c *Cacher) List(ctx context.Context, key string, resourceVersion uint64, filter FilterFunc, listObj runtime.Object) error {
|
||||||
return c.storage.List(ctx, key, filter, listObj)
|
return c.storage.List(ctx, key, resourceVersion, filter, listObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListFromMemory implements list operation (the same signature as List method)
|
// ListFromMemory implements list operation (the same signature as List method)
|
||||||
@ -344,7 +344,7 @@ func newCacherListerWatcher(storage Interface, resourcePrefix string, newListFun
|
|||||||
// Implements cache.ListerWatcher interface.
|
// Implements cache.ListerWatcher interface.
|
||||||
func (lw *cacherListerWatcher) List() (runtime.Object, error) {
|
func (lw *cacherListerWatcher) List() (runtime.Object, error) {
|
||||||
list := lw.newListFunc()
|
list := lw.newListFunc()
|
||||||
if err := lw.storage.List(context.TODO(), lw.resourcePrefix, Everything, list); err != nil {
|
if err := lw.storage.List(context.TODO(), lw.resourcePrefix, 0, Everything, list); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
|
@ -350,7 +350,7 @@ func (h *etcdHelper) decodeNodeList(nodes []*etcd.Node, filter storage.FilterFun
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements storage.Interface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) List(ctx context.Context, key string, filter storage.FilterFunc, listObj runtime.Object) error {
|
func (h *etcdHelper) List(ctx context.Context, key string, resourceVersion uint64, filter storage.FilterFunc, listObj runtime.Object) error {
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
glog.Errorf("Context is nil")
|
glog.Errorf("Context is nil")
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func TestList(t *testing.T) {
|
|||||||
var got api.PodList
|
var got api.PodList
|
||||||
// TODO: a sorted filter function could be applied such implied
|
// TODO: a sorted filter function could be applied such implied
|
||||||
// ordering on the returned list doesn't matter.
|
// ordering on the returned list doesn't matter.
|
||||||
err := helper.List(context.TODO(), key, storage.Everything, &got)
|
err := helper.List(context.TODO(), key, 0, storage.Everything, &got)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error %v", err)
|
t.Errorf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ func TestListFiltered(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var got api.PodList
|
var got api.PodList
|
||||||
err := helper.List(context.TODO(), key, filter, &got)
|
err := helper.List(context.TODO(), key, 0, filter, &got)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error %v", err)
|
t.Errorf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ func TestListAcrossDirectories(t *testing.T) {
|
|||||||
list.Items[2] = *returnedObj
|
list.Items[2] = *returnedObj
|
||||||
|
|
||||||
var got api.PodList
|
var got api.PodList
|
||||||
err := roothelper.List(context.TODO(), rootkey, storage.Everything, &got)
|
err := roothelper.List(context.TODO(), rootkey, 0, storage.Everything, &got)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error %v", err)
|
t.Errorf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,9 @@ type Interface interface {
|
|||||||
|
|
||||||
// List unmarshalls jsons found at directory defined by key and opaque them
|
// List unmarshalls jsons found at directory defined by key and opaque them
|
||||||
// into *List api object (an object that satisfies runtime.IsList definition).
|
// into *List api object (an object that satisfies runtime.IsList definition).
|
||||||
List(ctx context.Context, key string, filter FilterFunc, listObj runtime.Object) error
|
// The returned contents may be delayed, but it is guaranteed that they will
|
||||||
|
// be have at least 'resourceVersion'.
|
||||||
|
List(ctx context.Context, key string, resourceVersion uint64, filter FilterFunc, listObj runtime.Object) error
|
||||||
|
|
||||||
// GuaranteedUpdate keeps calling 'tryUpdate()' to update key 'key' (of type 'ptrToType')
|
// GuaranteedUpdate keeps calling 'tryUpdate()' to update key 'key' (of type 'ptrToType')
|
||||||
// retrying the update until success if there is index conflict.
|
// retrying the update until success if there is index conflict.
|
||||||
|
Loading…
Reference in New Issue
Block a user