Merge pull request #18655 from wojtek-t/versioned_list_options_in_server

Switch to versioned ListOptions in server.
This commit is contained in:
Wojciech Tyczynski
2015-12-22 10:57:09 +01:00
34 changed files with 218 additions and 232 deletions

View File

@@ -21,7 +21,6 @@ import (
"net/http"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/runtime"
@@ -51,7 +50,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, options *unversioned.ListOptions) (runtime.Object, error) {
func (rs *REST) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) {
servers := rs.GetServersToValidate()
wait := sync.WaitGroup{}

View File

@@ -19,15 +19,14 @@ package configmap
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store ConfigMaps.
type Registry interface {
ListConfigMaps(ctx api.Context, options *unversioned.ListOptions) (*extensions.ConfigMapList, error)
WatchConfigMaps(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error)
ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error)
WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetConfigMap(ctx api.Context, name string) (*extensions.ConfigMap, error)
CreateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error)
UpdateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error)
@@ -45,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListConfigMaps(ctx api.Context, options *unversioned.ListOptions) (*extensions.ConfigMapList, error) {
func (s *storage) ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error) {
obj, err := s.List(ctx, options)
if err != nil {
return nil, err
@@ -54,7 +53,7 @@ func (s *storage) ListConfigMaps(ctx api.Context, options *unversioned.ListOptio
return obj.(*extensions.ConfigMapList), err
}
func (s *storage) WatchConfigMaps(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -21,14 +21,13 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store ReplicationControllers.
type Registry interface {
ListControllers(ctx api.Context, options *unversioned.ListOptions) (*api.ReplicationControllerList, error)
WatchControllers(ctx api.Context, options *unversioned.ListOptions) (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)
@@ -46,8 +45,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListControllers(ctx api.Context, options *unversioned.ListOptions) (*api.ReplicationControllerList, error) {
if options != nil && options.FieldSelector.Selector != nil && !options.FieldSelector.Selector.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, options)
@@ -57,7 +56,7 @@ func (s *storage) ListControllers(ctx api.Context, options *unversioned.ListOpti
return obj.(*api.ReplicationControllerList), err
}
func (s *storage) WatchControllers(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchControllers(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -21,13 +21,12 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
)
// Registry is an interface for things that know how to store Deployments.
type Registry interface {
ListDeployments(ctx api.Context, options *unversioned.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)
@@ -44,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListDeployments(ctx api.Context, options *unversioned.ListOptions) (*extensions.DeploymentList, error) {
if options != nil && options.FieldSelector.Selector != nil && !options.FieldSelector.Selector.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, options)

View File

@@ -19,15 +19,14 @@ package endpoint
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store endpoints.
type Registry interface {
ListEndpoints(ctx api.Context, options *unversioned.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, options *unversioned.ListOptions) (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
}
@@ -43,7 +42,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListEndpoints(ctx api.Context, options *unversioned.ListOptions) (*api.EndpointsList, error) {
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
@@ -51,7 +50,7 @@ func (s *storage) ListEndpoints(ctx api.Context, options *unversioned.ListOption
return obj.(*api.EndpointsList), nil
}
func (s *storage) WatchEndpoints(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -162,20 +162,20 @@ func (e *Etcd) NewList() runtime.Object {
}
// List returns a list of items matching labels and field
func (e *Etcd) List(ctx api.Context, options *unversioned.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.Selector != nil {
label = options.LabelSelector.Selector
if options != nil && options.LabelSelector != nil {
label = options.LabelSelector
}
field := fields.Everything()
if options != nil && options.FieldSelector.Selector != nil {
field = options.FieldSelector.Selector
if options != nil && options.FieldSelector != nil {
field = options.FieldSelector
}
return e.ListPredicate(ctx, e.PredicateFunc(label, field), options)
}
// ListPredicate returns a list of all the items matching m.
func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *unversioned.ListOptions) (runtime.Object, error) {
func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *api.ListOptions) (runtime.Object, error) {
list := e.NewListFunc()
filterFunc := e.filterAndDecorateFunction(m)
if name, ok := m.MatchesSingle(); ok {
@@ -187,7 +187,7 @@ func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *unvers
}
if options == nil {
options = &unversioned.ListOptions{ResourceVersion: "0"}
options = &api.ListOptions{ResourceVersion: "0"}
}
err := e.Storage.List(ctx, e.KeyRootFunc(ctx), options.ResourceVersion, filterFunc, list)
return list, etcderr.InterpretListError(err, e.QualifiedResource)
@@ -432,7 +432,7 @@ func (e *Etcd) Delete(ctx api.Context, name string, options *api.DeleteOptions)
// are removing all objects of a given type) with the current API (it's technically
// possibly with etcd API, but watch is not delivered correctly then).
// It will be possible to fix it with v3 etcd API.
func (e *Etcd) DeleteCollection(ctx api.Context, options *api.DeleteOptions, listOptions *unversioned.ListOptions) (runtime.Object, error) {
func (e *Etcd) DeleteCollection(ctx api.Context, options *api.DeleteOptions, listOptions *api.ListOptions) (runtime.Object, error) {
listObj, err := e.List(ctx, listOptions)
if err != nil {
return nil, err
@@ -474,14 +474,14 @@ 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, options *unversioned.ListOptions) (watch.Interface, error) {
func (e *Etcd) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
label := labels.Everything()
if options != nil && options.LabelSelector.Selector != nil {
label = options.LabelSelector.Selector
if options != nil && options.LabelSelector != nil {
label = options.LabelSelector
}
field := fields.Everything()
if options != nil && options.FieldSelector.Selector != nil {
field = options.FieldSelector.Selector
if options != nil && options.FieldSelector != nil {
field = options.FieldSelector
}
resourceVersion := ""
if options != nil {

View File

@@ -500,7 +500,7 @@ func TestEtcdDeleteCollection(t *testing.T) {
}
// Delete all pods.
deleted, err := registry.DeleteCollection(testContext, nil, &unversioned.ListOptions{})
deleted, err := registry.DeleteCollection(testContext, nil, &api.ListOptions{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
@@ -537,7 +537,7 @@ func TestEtcdDeleteCollectionWithWatch(t *testing.T) {
t.Fatalf("Unexpected error: %v", err)
}
if _, err := registry.DeleteCollection(testContext, nil, &unversioned.ListOptions{}); err != nil {
if _, err := registry.DeleteCollection(testContext, nil, &api.ListOptions{}); err != nil {
t.Fatalf("Unexpected error: %v", err)
}

View File

@@ -19,14 +19,13 @@ package namespace
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store Namespace objects.
type Registry interface {
ListNamespaces(ctx api.Context, options *unversioned.ListOptions) (*api.NamespaceList, error)
WatchNamespaces(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error)
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)
CreateNamespace(ctx api.Context, namespace *api.Namespace) error
UpdateNamespace(ctx api.Context, namespace *api.Namespace) error
@@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListNamespaces(ctx api.Context, options *unversioned.ListOptions) (*api.NamespaceList, error) {
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
@@ -52,7 +51,7 @@ func (s *storage) ListNamespaces(ctx api.Context, options *unversioned.ListOptio
return obj.(*api.NamespaceList), nil
}
func (s *storage) WatchNamespaces(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchNamespaces(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -19,18 +19,17 @@ package node
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store node.
type Registry interface {
ListNodes(ctx api.Context, options *unversioned.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, options *unversioned.ListOptions) (watch.Interface, error)
WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
}
// storage puts strong typing around storage calls
@@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListNodes(ctx api.Context, options *unversioned.ListOptions) (*api.NodeList, error) {
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
@@ -63,7 +62,7 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error {
return err
}
func (s *storage) WatchNodes(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -22,7 +22,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
@@ -35,7 +34,7 @@ type EndpointRegistry struct {
lock sync.Mutex
}
func (e *EndpointRegistry) ListEndpoints(ctx api.Context, options *unversioned.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()
@@ -60,7 +59,7 @@ func (e *EndpointRegistry) GetEndpoints(ctx api.Context, name string) (*api.Endp
return nil, errors.NewNotFound(api.Resource("endpoints"), name)
}
func (e *EndpointRegistry) WatchEndpoints(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (e *EndpointRegistry) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return nil, fmt.Errorf("unimplemented!")
}

View File

@@ -21,7 +21,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
@@ -58,7 +57,7 @@ func (r *NodeRegistry) SetError(err error) {
r.Err = err
}
func (r *NodeRegistry) ListNodes(ctx api.Context, options *unversioned.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
@@ -111,6 +110,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error {
return r.Err
}
func (r *NodeRegistry) WatchNodes(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (r *NodeRegistry) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return nil, r.Err
}

View File

@@ -20,7 +20,6 @@ import (
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
@@ -46,7 +45,7 @@ func (r *ServiceRegistry) SetError(err error) {
r.Err = err
}
func (r *ServiceRegistry) ListServices(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceList, error) {
func (r *ServiceRegistry) ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error) {
r.mu.Lock()
defer r.mu.Unlock()
@@ -107,7 +106,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api
return svc, r.Err
}
func (r *ServiceRegistry) WatchServices(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (r *ServiceRegistry) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
r.mu.Lock()
defer r.mu.Unlock()

View File

@@ -19,14 +19,13 @@ package secret
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store Secret objects.
type Registry interface {
ListSecrets(ctx api.Context, options *unversioned.ListOptions) (*api.SecretList, error)
WatchSecrets(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error)
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)
CreateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error)
UpdateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error)
@@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListSecrets(ctx api.Context, options *unversioned.ListOptions) (*api.SecretList, error) {
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
@@ -52,7 +51,7 @@ func (s *storage) ListSecrets(ctx api.Context, options *unversioned.ListOptions)
return obj.(*api.SecretList), nil
}
func (s *storage) WatchSecrets(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchSecrets(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -22,7 +22,6 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/util"
@@ -93,7 +92,7 @@ func (c *Repair) RunOnce() error {
}
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
options := &unversioned.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
list, err := c.registry.ListServices(ctx, options)
if err != nil {
return fmt.Errorf("unable to refresh the service IP block: %v", err)

View File

@@ -21,7 +21,6 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/util"
@@ -80,7 +79,7 @@ func (c *Repair) RunOnce() error {
}
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
options := &unversioned.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
list, err := c.registry.ListServices(ctx, options)
if err != nil {
return fmt.Errorf("unable to refresh the port block: %v", err)

View File

@@ -19,18 +19,17 @@ package service
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store services.
type Registry interface {
ListServices(ctx api.Context, options *unversioned.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, options *unversioned.ListOptions) (watch.Interface, error)
WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
}
// storage puts strong typing around storage calls
@@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListServices(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceList, error) {
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
@@ -81,7 +80,7 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service
return obj.(*api.Service), nil
}
func (s *storage) WatchServices(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -178,13 +178,13 @@ 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, options *unversioned.ListOptions) (runtime.Object, error) {
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, options *unversioned.ListOptions) (watch.Interface, error) {
func (rs *REST) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return rs.registry.WatchServices(ctx, options)
}

View File

@@ -19,14 +19,13 @@ package serviceaccount
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store ServiceAccount objects.
type Registry interface {
ListServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceAccountList, error)
WatchServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error)
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)
CreateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error
UpdateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error
@@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceAccountList, error) {
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
@@ -52,7 +51,7 @@ func (s *storage) ListServiceAccounts(ctx api.Context, options *unversioned.List
return obj.(*api.ServiceAccountList), nil
}
func (s *storage) WatchServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchServiceAccounts(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}

View File

@@ -302,6 +302,13 @@ func (t *thirdPartyResourceDataCreator) New(kind unversioned.GroupVersionKind) (
return nil, fmt.Errorf("unknown kind %v", kind)
}
return &extensions.ThirdPartyResourceDataList{}, nil
case "ListOptions":
if apiutil.GetGroupVersion(t.group, t.version) == kind.GroupVersion().String() {
// Translate third party group to external group.
gvk := latest.ExternalVersions[0].WithKind(kind.Kind)
return t.delegate.New(gvk)
}
return t.delegate.New(kind)
default:
return t.delegate.New(kind)
}

View File

@@ -19,15 +19,14 @@ package thirdpartyresourcedata
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
type Registry interface {
ListThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (*extensions.ThirdPartyResourceDataList, error)
WatchThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error)
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)
CreateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error)
UpdateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error)
@@ -45,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (*extensions.ThirdPartyResourceDataList, error) {
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
@@ -53,7 +52,7 @@ func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *unversion
return obj.(*extensions.ThirdPartyResourceDataList), nil
}
func (s *storage) WatchThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) {
func (s *storage) WatchThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options)
}