Merge pull request #44779 from enj/enj/r/etcd_default_name_copy

Automatic merge from submit-queue (batch tested with PRs 44837, 44779, 44492)

Default ObjectNameFunc for all REST Stores

All `Store`s in Kubernetes follow the same logic for determining the name of an object.  This change makes it so that `CompleteWithOptions` defaults the `ObjectNameFunc` if it is not specified.  Thus a user does not need to remember to use `ObjectMeta.Name`.  Using the wrong field as the name can lead to an object which has a name that bypasses normal object name validation.

Signed-off-by: Monis Khan <mkhan@redhat.com>

cc @liggitt @soltysh for review

**Release note**:

```
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-04-24 07:55:59 -07:00 committed by GitHub
commit c90faa8071
39 changed files with 124 additions and 228 deletions

View File

@ -48,12 +48,9 @@ func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo
// NewREST returns a RESTStorage object that will work against clusters. // NewREST returns a RESTStorage object that will work against clusters.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &federation.Cluster{} }, NewFunc: func() runtime.Object { return &federation.Cluster{} },
NewListFunc: func() runtime.Object { return &federation.ClusterList{} }, NewListFunc: func() runtime.Object { return &federation.ClusterList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*federation.Cluster).Name, nil
},
PredicateFunc: cluster.MatchCluster, PredicateFunc: cluster.MatchCluster,
QualifiedResource: federation.Resource("clusters"), QualifiedResource: federation.Resource("clusters"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusters"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusters"),

View File

@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against replication controllers. // NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &appsapi.StatefulSet{} }, NewFunc: func() runtime.Object { return &appsapi.StatefulSet{} },
NewListFunc: func() runtime.Object { return &appsapi.StatefulSetList{} }, NewListFunc: func() runtime.Object { return &appsapi.StatefulSetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*appsapi.StatefulSet).Name, nil
},
PredicateFunc: petset.MatchStatefulSet, PredicateFunc: petset.MatchStatefulSet,
QualifiedResource: appsapi.Resource("statefulsets"), QualifiedResource: appsapi.Resource("statefulsets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("statefulsets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("statefulsets"),

View File

@ -36,12 +36,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers. // NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} }, NewFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} },
NewListFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscalerList{} }, NewListFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscalerList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*autoscaling.HorizontalPodAutoscaler).Name, nil
},
PredicateFunc: horizontalpodautoscaler.MatchAutoscaler, PredicateFunc: horizontalpodautoscaler.MatchAutoscaler,
QualifiedResource: autoscaling.Resource("horizontalpodautoscalers"), QualifiedResource: autoscaling.Resource("horizontalpodautoscalers"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("horizontalpodautoscalers"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("horizontalpodautoscalers"),

View File

@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against CronJobs. // NewREST returns a RESTStorage object that will work against CronJobs.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &batch.CronJob{} }, NewFunc: func() runtime.Object { return &batch.CronJob{} },
NewListFunc: func() runtime.Object { return &batch.CronJobList{} }, NewListFunc: func() runtime.Object { return &batch.CronJobList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*batch.CronJob).Name, nil
},
PredicateFunc: cronjob.MatchCronJob, PredicateFunc: cronjob.MatchCronJob,
QualifiedResource: batch.Resource("cronjobs"), QualifiedResource: batch.Resource("cronjobs"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("cronjobs"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("cronjobs"),

View File

@ -52,12 +52,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against Jobs. // NewREST returns a RESTStorage object that will work against Jobs.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &batch.Job{} }, NewFunc: func() runtime.Object { return &batch.Job{} },
NewListFunc: func() runtime.Object { return &batch.JobList{} }, NewListFunc: func() runtime.Object { return &batch.JobList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*batch.Job).Name, nil
},
PredicateFunc: job.MatchJob, PredicateFunc: job.MatchJob,
QualifiedResource: batch.Resource("jobs"), QualifiedResource: batch.Resource("jobs"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("jobs"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("jobs"),

View File

@ -36,12 +36,9 @@ type REST struct {
// NewREST returns a registry which will store CertificateSigningRequest in the given helper // NewREST returns a registry which will store CertificateSigningRequest in the given helper
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ApprovalREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ApprovalREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} }, NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} },
NewListFunc: func() runtime.Object { return &certificates.CertificateSigningRequestList{} }, NewListFunc: func() runtime.Object { return &certificates.CertificateSigningRequestList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*certificates.CertificateSigningRequest).Name, nil
},
PredicateFunc: csrregistry.Matcher, PredicateFunc: csrregistry.Matcher,
QualifiedResource: certificates.Resource("certificatesigningrequests"), QualifiedResource: certificates.Resource("certificatesigningrequests"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("certificatesigningrequests"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("certificatesigningrequests"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work with ConfigMap objects. // NewREST returns a RESTStorage object that will work with ConfigMap objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ConfigMap{} }, NewFunc: func() runtime.Object { return &api.ConfigMap{} },
NewListFunc: func() runtime.Object { return &api.ConfigMapList{} }, NewListFunc: func() runtime.Object { return &api.ConfigMapList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ConfigMap).Name, nil
},
PredicateFunc: configmap.MatchConfigMap, PredicateFunc: configmap.MatchConfigMap,
QualifiedResource: api.Resource("configmaps"), QualifiedResource: api.Resource("configmaps"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("configmaps"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("configmaps"),

View File

@ -33,12 +33,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against endpoints. // NewREST returns a RESTStorage object that will work against endpoints.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Endpoints{} }, NewFunc: func() runtime.Object { return &api.Endpoints{} },
NewListFunc: func() runtime.Object { return &api.EndpointsList{} }, NewListFunc: func() runtime.Object { return &api.EndpointsList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Endpoints).Name, nil
},
PredicateFunc: endpoint.MatchEndpoints, PredicateFunc: endpoint.MatchEndpoints,
QualifiedResource: api.Resource("endpoints"), QualifiedResource: api.Resource("endpoints"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("endpoints"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("endpoints"),

View File

@ -43,12 +43,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) *REST {
opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Event{} }, NewFunc: func() runtime.Object { return &api.Event{} },
NewListFunc: func() runtime.Object { return &api.EventList{} }, NewListFunc: func() runtime.Object { return &api.EventList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Event).Name, nil
},
PredicateFunc: event.MatchEvent, PredicateFunc: event.MatchEvent,
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) { TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
return ttl, nil return ttl, nil

View File

@ -33,12 +33,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers. // NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.LimitRange{} }, NewFunc: func() runtime.Object { return &api.LimitRange{} },
NewListFunc: func() runtime.Object { return &api.LimitRangeList{} }, NewListFunc: func() runtime.Object { return &api.LimitRangeList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.LimitRange).Name, nil
},
PredicateFunc: limitrange.MatchLimitRange, PredicateFunc: limitrange.MatchLimitRange,
QualifiedResource: api.Resource("limitranges"), QualifiedResource: api.Resource("limitranges"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("limitranges"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("limitranges"),

View File

@ -52,12 +52,9 @@ type FinalizeREST struct {
// NewREST returns a RESTStorage object that will work against namespaces. // NewREST returns a RESTStorage object that will work against namespaces.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Namespace{} }, NewFunc: func() runtime.Object { return &api.Namespace{} },
NewListFunc: func() runtime.Object { return &api.NamespaceList{} }, NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Namespace).Name, nil
},
PredicateFunc: namespace.MatchNamespace, PredicateFunc: namespace.MatchNamespace,
QualifiedResource: api.Resource("namespaces"), QualifiedResource: api.Resource("namespaces"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("namespaces"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("namespaces"),

View File

@ -72,12 +72,9 @@ func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo
// NewStorage returns a NodeStorage object that will work against nodes. // NewStorage returns a NodeStorage object that will work against nodes.
func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client.KubeletClientConfig, proxyTransport http.RoundTripper) (*NodeStorage, error) { func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client.KubeletClientConfig, proxyTransport http.RoundTripper) (*NodeStorage, error) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Node{} }, NewFunc: func() runtime.Object { return &api.Node{} },
NewListFunc: func() runtime.Object { return &api.NodeList{} }, NewListFunc: func() runtime.Object { return &api.NodeList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Node).Name, nil
},
PredicateFunc: node.MatchNode, PredicateFunc: node.MatchNode,
QualifiedResource: api.Resource("nodes"), QualifiedResource: api.Resource("nodes"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("nodes"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("nodes"),

View File

@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against persistent volumes. // NewREST returns a RESTStorage object that will work against persistent volumes.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PersistentVolume{} }, NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} }, NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PersistentVolume).Name, nil
},
PredicateFunc: persistentvolume.MatchPersistentVolumes, PredicateFunc: persistentvolume.MatchPersistentVolumes,
QualifiedResource: api.Resource("persistentvolumes"), QualifiedResource: api.Resource("persistentvolumes"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumes"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumes"),

View File

@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against persistent volume claims. // NewREST returns a RESTStorage object that will work against persistent volume claims.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} }, NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} }, NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PersistentVolumeClaim).Name, nil
},
PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim, PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim,
QualifiedResource: api.Resource("persistentvolumeclaims"), QualifiedResource: api.Resource("persistentvolumeclaims"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumeclaims"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumeclaims"),

View File

@ -62,12 +62,9 @@ type REST struct {
// NewStorage returns a RESTStorage object that will work against pods. // NewStorage returns a RESTStorage object that will work against pods.
func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGetter, proxyTransport http.RoundTripper, podDisruptionBudgetClient policyclient.PodDisruptionBudgetsGetter) PodStorage { func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGetter, proxyTransport http.RoundTripper, podDisruptionBudgetClient policyclient.PodDisruptionBudgetsGetter) PodStorage {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Pod{} }, NewFunc: func() runtime.Object { return &api.Pod{} },
NewListFunc: func() runtime.Object { return &api.PodList{} }, NewListFunc: func() runtime.Object { return &api.PodList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Pod).Name, nil
},
PredicateFunc: pod.MatchPod, PredicateFunc: pod.MatchPod,
QualifiedResource: api.Resource("pods"), QualifiedResource: api.Resource("pods"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("pods"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("pods"),

View File

@ -32,12 +32,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against pod templates. // NewREST returns a RESTStorage object that will work against pod templates.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PodTemplate{} }, NewFunc: func() runtime.Object { return &api.PodTemplate{} },
NewListFunc: func() runtime.Object { return &api.PodTemplateList{} }, NewListFunc: func() runtime.Object { return &api.PodTemplateList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PodTemplate).Name, nil
},
PredicateFunc: podtemplate.MatchPodTemplate, PredicateFunc: podtemplate.MatchPodTemplate,
QualifiedResource: api.Resource("podtemplates"), QualifiedResource: api.Resource("podtemplates"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podtemplates"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podtemplates"),

View File

@ -61,12 +61,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against replication controllers. // NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ReplicationController{} }, NewFunc: func() runtime.Object { return &api.ReplicationController{} },
NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} }, NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ReplicationController).Name, nil
},
PredicateFunc: replicationcontroller.MatchController, PredicateFunc: replicationcontroller.MatchController,
QualifiedResource: api.Resource("replicationcontrollers"), QualifiedResource: api.Resource("replicationcontrollers"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicationcontrollers"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicationcontrollers"),

View File

@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against resource quotas. // NewREST returns a RESTStorage object that will work against resource quotas.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ResourceQuota{} }, NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} }, NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ResourceQuota).Name, nil
},
PredicateFunc: resourcequota.MatchResourceQuota, PredicateFunc: resourcequota.MatchResourceQuota,
QualifiedResource: api.Resource("resourcequotas"), QualifiedResource: api.Resource("resourcequotas"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("resourcequotas"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("resourcequotas"),

View File

@ -32,12 +32,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against secrets. // NewREST returns a RESTStorage object that will work against secrets.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Secret{} }, NewFunc: func() runtime.Object { return &api.Secret{} },
NewListFunc: func() runtime.Object { return &api.SecretList{} }, NewListFunc: func() runtime.Object { return &api.SecretList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Secret).Name, nil
},
PredicateFunc: secret.Matcher, PredicateFunc: secret.Matcher,
QualifiedResource: api.Resource("secrets"), QualifiedResource: api.Resource("secrets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("secrets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("secrets"),

View File

@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against services. // NewREST returns a RESTStorage object that will work against services.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Service{} }, NewFunc: func() runtime.Object { return &api.Service{} },
NewListFunc: func() runtime.Object { return &api.ServiceList{} }, NewListFunc: func() runtime.Object { return &api.ServiceList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Service).Name, nil
},
PredicateFunc: service.MatchServices, PredicateFunc: service.MatchServices,
QualifiedResource: api.Resource("services"), QualifiedResource: api.Resource("services"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("services"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("services"),

View File

@ -33,12 +33,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against service accounts. // NewREST returns a RESTStorage object that will work against service accounts.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ServiceAccount{} }, NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} }, NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ServiceAccount).Name, nil
},
PredicateFunc: serviceaccount.Matcher, PredicateFunc: serviceaccount.Matcher,
QualifiedResource: api.Resource("serviceaccounts"), QualifiedResource: api.Resource("serviceaccounts"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("serviceaccounts"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("serviceaccounts"),

View File

@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against DaemonSets. // NewREST returns a RESTStorage object that will work against DaemonSets.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} }, NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} }, NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.DaemonSet).Name, nil
},
PredicateFunc: daemonset.MatchDaemonSet, PredicateFunc: daemonset.MatchDaemonSet,
QualifiedResource: extensions.Resource("daemonsets"), QualifiedResource: extensions.Resource("daemonsets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("daemonsets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("daemonsets"),

View File

@ -63,12 +63,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against deployments. // NewREST returns a RESTStorage object that will work against deployments.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.Deployment{} }, NewFunc: func() runtime.Object { return &extensions.Deployment{} },
NewListFunc: func() runtime.Object { return &extensions.DeploymentList{} }, NewListFunc: func() runtime.Object { return &extensions.DeploymentList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.Deployment).Name, nil
},
PredicateFunc: deployment.MatchDeployment, PredicateFunc: deployment.MatchDeployment,
QualifiedResource: extensions.Resource("deployments"), QualifiedResource: extensions.Resource("deployments"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("deployments"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("deployments"),

View File

@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against replication controllers. // NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.Ingress{} }, NewFunc: func() runtime.Object { return &extensions.Ingress{} },
NewListFunc: func() runtime.Object { return &extensions.IngressList{} }, NewListFunc: func() runtime.Object { return &extensions.IngressList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.Ingress).Name, nil
},
PredicateFunc: ingress.MatchIngress, PredicateFunc: ingress.MatchIngress,
QualifiedResource: extensions.Resource("ingresses"), QualifiedResource: extensions.Resource("ingresses"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("ingresses"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("ingresses"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against network policies. // NewREST returns a RESTStorage object that will work against network policies.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensionsapi.NetworkPolicy{} }, NewFunc: func() runtime.Object { return &extensionsapi.NetworkPolicy{} },
NewListFunc: func() runtime.Object { return &extensionsapi.NetworkPolicyList{} }, NewListFunc: func() runtime.Object { return &extensionsapi.NetworkPolicyList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensionsapi.NetworkPolicy).Name, nil
},
PredicateFunc: networkpolicy.MatchNetworkPolicy, PredicateFunc: networkpolicy.MatchNetworkPolicy,
QualifiedResource: extensionsapi.Resource("networkpolicies"), QualifiedResource: extensionsapi.Resource("networkpolicies"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("networkpolicies"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("networkpolicies"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against PodSecurityPolicy objects. // NewREST returns a RESTStorage object that will work against PodSecurityPolicy objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.PodSecurityPolicy{} }, NewFunc: func() runtime.Object { return &extensions.PodSecurityPolicy{} },
NewListFunc: func() runtime.Object { return &extensions.PodSecurityPolicyList{} }, NewListFunc: func() runtime.Object { return &extensions.PodSecurityPolicyList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.PodSecurityPolicy).Name, nil
},
PredicateFunc: podsecuritypolicy.MatchPodSecurityPolicy, PredicateFunc: podsecuritypolicy.MatchPodSecurityPolicy,
QualifiedResource: extensions.Resource("podsecuritypolicies"), QualifiedResource: extensions.Resource("podsecuritypolicies"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podsecuritypolicies"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podsecuritypolicies"),

View File

@ -60,12 +60,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ReplicaSet. // NewREST returns a RESTStorage object that will work against ReplicaSet.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.ReplicaSet{} }, NewFunc: func() runtime.Object { return &extensions.ReplicaSet{} },
NewListFunc: func() runtime.Object { return &extensions.ReplicaSetList{} }, NewListFunc: func() runtime.Object { return &extensions.ReplicaSetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.ReplicaSet).Name, nil
},
PredicateFunc: replicaset.MatchReplicaSet, PredicateFunc: replicaset.MatchReplicaSet,
QualifiedResource: extensions.Resource("replicasets"), QualifiedResource: extensions.Resource("replicasets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicasets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicasets"),

View File

@ -43,12 +43,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResource{} }, NewFunc: func() runtime.Object { return &extensions.ThirdPartyResource{} },
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} }, NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.ThirdPartyResource).Name, nil
},
PredicateFunc: thirdpartyresource.Matcher, PredicateFunc: thirdpartyresource.Matcher,
QualifiedResource: resource, QualifiedResource: resource,
WatchCacheSize: cachesize.GetWatchCacheSizeByResource(resource.Resource), WatchCacheSize: cachesize.GetWatchCacheSizeByResource(resource.Resource),

View File

@ -47,12 +47,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter, group, kind string) *REST {
opts.ResourcePrefix = "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s" opts.ResourcePrefix = "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s"
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} }, NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} },
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} }, NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.ThirdPartyResourceData).Name, nil
},
PredicateFunc: thirdpartyresourcedata.Matcher, PredicateFunc: thirdpartyresourcedata.Matcher,
QualifiedResource: resource, QualifiedResource: resource,
WatchCacheSize: cachesize.GetWatchCacheSizeByResource(resource.Resource), WatchCacheSize: cachesize.GetWatchCacheSizeByResource(resource.Resource),

View File

@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against pod disruption budgets. // NewREST returns a RESTStorage object that will work against pod disruption budgets.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) { func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &policyapi.PodDisruptionBudget{} }, NewFunc: func() runtime.Object { return &policyapi.PodDisruptionBudget{} },
NewListFunc: func() runtime.Object { return &policyapi.PodDisruptionBudgetList{} }, NewListFunc: func() runtime.Object { return &policyapi.PodDisruptionBudgetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*policyapi.PodDisruptionBudget).Name, nil
},
PredicateFunc: poddisruptionbudget.MatchPodDisruptionBudget, PredicateFunc: poddisruptionbudget.MatchPodDisruptionBudget,
QualifiedResource: policyapi.Resource("poddisruptionbudgets"), QualifiedResource: policyapi.Resource("poddisruptionbudgets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("poddisruptionbudgets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("poddisruptionbudgets"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ClusterRole objects. // NewREST returns a RESTStorage object that will work against ClusterRole objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &rbac.ClusterRole{} }, NewFunc: func() runtime.Object { return &rbac.ClusterRole{} },
NewListFunc: func() runtime.Object { return &rbac.ClusterRoleList{} }, NewListFunc: func() runtime.Object { return &rbac.ClusterRoleList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*rbac.ClusterRole).Name, nil
},
PredicateFunc: clusterrole.Matcher, PredicateFunc: clusterrole.Matcher,
QualifiedResource: rbac.Resource("clusterroles"), QualifiedResource: rbac.Resource("clusterroles"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterroles"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterroles"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ClusterRoleBinding objects. // NewREST returns a RESTStorage object that will work against ClusterRoleBinding objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &rbac.ClusterRoleBinding{} }, NewFunc: func() runtime.Object { return &rbac.ClusterRoleBinding{} },
NewListFunc: func() runtime.Object { return &rbac.ClusterRoleBindingList{} }, NewListFunc: func() runtime.Object { return &rbac.ClusterRoleBindingList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*rbac.ClusterRoleBinding).Name, nil
},
PredicateFunc: clusterrolebinding.Matcher, PredicateFunc: clusterrolebinding.Matcher,
QualifiedResource: rbac.Resource("clusterrolebindings"), QualifiedResource: rbac.Resource("clusterrolebindings"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterrolebindings"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterrolebindings"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against Role objects. // NewREST returns a RESTStorage object that will work against Role objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &rbac.Role{} }, NewFunc: func() runtime.Object { return &rbac.Role{} },
NewListFunc: func() runtime.Object { return &rbac.RoleList{} }, NewListFunc: func() runtime.Object { return &rbac.RoleList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*rbac.Role).Name, nil
},
PredicateFunc: role.Matcher, PredicateFunc: role.Matcher,
QualifiedResource: rbac.Resource("roles"), QualifiedResource: rbac.Resource("roles"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("roles"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("roles"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against RoleBinding objects. // NewREST returns a RESTStorage object that will work against RoleBinding objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &rbac.RoleBinding{} }, NewFunc: func() runtime.Object { return &rbac.RoleBinding{} },
NewListFunc: func() runtime.Object { return &rbac.RoleBindingList{} }, NewListFunc: func() runtime.Object { return &rbac.RoleBindingList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*rbac.RoleBinding).Name, nil
},
PredicateFunc: rolebinding.Matcher, PredicateFunc: rolebinding.Matcher,
QualifiedResource: rbac.Resource("rolebindings"), QualifiedResource: rbac.Resource("rolebindings"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("rolebindings"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("rolebindings"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against replication controllers. // NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &settingsapi.PodPreset{} }, NewFunc: func() runtime.Object { return &settingsapi.PodPreset{} },
NewListFunc: func() runtime.Object { return &settingsapi.PodPresetList{} }, NewListFunc: func() runtime.Object { return &settingsapi.PodPresetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*settingsapi.PodPreset).GetName(), nil
},
PredicateFunc: podpreset.Matcher, PredicateFunc: podpreset.Matcher,
QualifiedResource: settingsapi.Resource("podpresets"), QualifiedResource: settingsapi.Resource("podpresets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podpresets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podpresets"),

View File

@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against persistent volumes. // NewREST returns a RESTStorage object that will work against persistent volumes.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST { func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: api.Scheme, Copier: api.Scheme,
NewFunc: func() runtime.Object { return &storageapi.StorageClass{} }, NewFunc: func() runtime.Object { return &storageapi.StorageClass{} },
NewListFunc: func() runtime.Object { return &storageapi.StorageClassList{} }, NewListFunc: func() runtime.Object { return &storageapi.StorageClassList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*storageapi.StorageClass).Name, nil
},
PredicateFunc: storageclass.MatchStorageClasses, PredicateFunc: storageclass.MatchStorageClasses,
QualifiedResource: storageapi.Resource("storageclasses"), QualifiedResource: storageapi.Resource("storageclasses"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("storageclass"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("storageclass"),

View File

@ -1194,6 +1194,16 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
e.EnableGarbageCollection = opts.EnableGarbageCollection e.EnableGarbageCollection = opts.EnableGarbageCollection
if e.ObjectNameFunc == nil {
e.ObjectNameFunc = func(obj runtime.Object) (string, error) {
accessor, err := meta.Accessor(obj)
if err != nil {
return "", err
}
return accessor.GetName(), nil
}
}
if e.Storage == nil { if e.Storage == nil {
capacity := DefaultWatchCacheSize capacity := DefaultWatchCacheSize
if e.WatchCacheSize != 0 { if e.WatchCacheSize != 0 {

View File

@ -33,12 +33,9 @@ type REST struct {
func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST { func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST {
strategy := apiservice.NewStrategy(scheme) strategy := apiservice.NewStrategy(scheme)
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: scheme, Copier: scheme,
NewFunc: func() runtime.Object { return &apiregistration.APIService{} }, NewFunc: func() runtime.Object { return &apiregistration.APIService{} },
NewListFunc: func() runtime.Object { return &apiregistration.APIServiceList{} }, NewListFunc: func() runtime.Object { return &apiregistration.APIServiceList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*apiregistration.APIService).Name, nil
},
PredicateFunc: apiservice.MatchAPIService, PredicateFunc: apiservice.MatchAPIService,
QualifiedResource: apiregistration.Resource("apiservices"), QualifiedResource: apiregistration.Resource("apiservices"),
WatchCacheSize: 100, WatchCacheSize: 100,

View File

@ -33,12 +33,9 @@ func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST
strategy := NewStrategy(scheme) strategy := NewStrategy(scheme)
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: scheme, Copier: scheme,
NewFunc: func() runtime.Object { return &wardle.Flunder{} }, NewFunc: func() runtime.Object { return &wardle.Flunder{} },
NewListFunc: func() runtime.Object { return &wardle.FlunderList{} }, NewListFunc: func() runtime.Object { return &wardle.FlunderList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*wardle.Flunder).Name, nil
},
PredicateFunc: MatchFlunder, PredicateFunc: MatchFlunder,
QualifiedResource: wardle.Resource("flunders"), QualifiedResource: wardle.Resource("flunders"),