Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default ObjectNameFunc for all REST Stores #44779

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions federation/registry/cluster/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo
// NewREST returns a RESTStorage object that will work against clusters.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &federation.Cluster{} },
NewListFunc: func() runtime.Object { return &federation.ClusterList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*federation.Cluster).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &federation.Cluster{} },
NewListFunc: func() runtime.Object { return &federation.ClusterList{} },
PredicateFunc: cluster.MatchCluster,
QualifiedResource: federation.Resource("clusters"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusters"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/apps/petset/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &appsapi.StatefulSet{} },
NewListFunc: func() runtime.Object { return &appsapi.StatefulSetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*appsapi.StatefulSet).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &appsapi.StatefulSet{} },
NewListFunc: func() runtime.Object { return &appsapi.StatefulSetList{} },
PredicateFunc: petset.MatchStatefulSet,
QualifiedResource: appsapi.Resource("statefulsets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("statefulsets"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} },
NewListFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscalerList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*autoscaling.HorizontalPodAutoscaler).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} },
NewListFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscalerList{} },
PredicateFunc: horizontalpodautoscaler.MatchAutoscaler,
QualifiedResource: autoscaling.Resource("horizontalpodautoscalers"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("horizontalpodautoscalers"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/batch/cronjob/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against CronJobs.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &batch.CronJob{} },
NewListFunc: func() runtime.Object { return &batch.CronJobList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*batch.CronJob).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &batch.CronJob{} },
NewListFunc: func() runtime.Object { return &batch.CronJobList{} },
PredicateFunc: cronjob.MatchCronJob,
QualifiedResource: batch.Resource("cronjobs"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("cronjobs"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/batch/job/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against Jobs.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &batch.Job{} },
NewListFunc: func() runtime.Object { return &batch.JobList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*batch.Job).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &batch.Job{} },
NewListFunc: func() runtime.Object { return &batch.JobList{} },
PredicateFunc: job.MatchJob,
QualifiedResource: batch.Resource("jobs"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("jobs"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/certificates/certificates/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@ type REST struct {
// NewREST returns a registry which will store CertificateSigningRequest in the given helper
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ApprovalREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} },
NewListFunc: func() runtime.Object { return &certificates.CertificateSigningRequestList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*certificates.CertificateSigningRequest).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} },
NewListFunc: func() runtime.Object { return &certificates.CertificateSigningRequestList{} },
PredicateFunc: csrregistry.Matcher,
QualifiedResource: certificates.Resource("certificatesigningrequests"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("certificatesigningrequests"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/configmap/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work with ConfigMap objects.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ConfigMap{} },
NewListFunc: func() runtime.Object { return &api.ConfigMapList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ConfigMap).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ConfigMap{} },
NewListFunc: func() runtime.Object { return &api.ConfigMapList{} },
PredicateFunc: configmap.MatchConfigMap,
QualifiedResource: api.Resource("configmaps"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("configmaps"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/endpoint/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against endpoints.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Endpoints{} },
NewListFunc: func() runtime.Object { return &api.EndpointsList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Endpoints).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Endpoints{} },
NewListFunc: func() runtime.Object { return &api.EndpointsList{} },
PredicateFunc: endpoint.MatchEndpoints,
QualifiedResource: api.Resource("endpoints"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("endpoints"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/event/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) *REST {
opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage

store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Event{} },
NewListFunc: func() runtime.Object { return &api.EventList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Event).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Event{} },
NewListFunc: func() runtime.Object { return &api.EventList{} },
PredicateFunc: event.MatchEvent,
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
return ttl, nil
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/limitrange/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.LimitRange{} },
NewListFunc: func() runtime.Object { return &api.LimitRangeList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.LimitRange).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.LimitRange{} },
NewListFunc: func() runtime.Object { return &api.LimitRangeList{} },
PredicateFunc: limitrange.MatchLimitRange,
QualifiedResource: api.Resource("limitranges"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("limitranges"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/namespace/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ type FinalizeREST struct {
// NewREST returns a RESTStorage object that will work against namespaces.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Namespace{} },
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Namespace).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Namespace{} },
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
PredicateFunc: namespace.MatchNamespace,
QualifiedResource: api.Resource("namespaces"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("namespaces"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/node/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,9 @@ func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo
// NewStorage returns a NodeStorage object that will work against nodes.
func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client.KubeletClientConfig, proxyTransport http.RoundTripper) (*NodeStorage, error) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Node{} },
NewListFunc: func() runtime.Object { return &api.NodeList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Node).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Node{} },
NewListFunc: func() runtime.Object { return &api.NodeList{} },
PredicateFunc: node.MatchNode,
QualifiedResource: api.Resource("nodes"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("nodes"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/persistentvolume/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against persistent volumes.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PersistentVolume).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} },
PredicateFunc: persistentvolume.MatchPersistentVolumes,
QualifiedResource: api.Resource("persistentvolumes"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumes"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/persistentvolumeclaim/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against persistent volume claims.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PersistentVolumeClaim).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} },
PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim,
QualifiedResource: api.Resource("persistentvolumeclaims"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumeclaims"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/pod/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ type REST struct {
// 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 {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Pod{} },
NewListFunc: func() runtime.Object { return &api.PodList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Pod).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Pod{} },
NewListFunc: func() runtime.Object { return &api.PodList{} },
PredicateFunc: pod.MatchPod,
QualifiedResource: api.Resource("pods"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("pods"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/podtemplate/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against pod templates.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
NewListFunc: func() runtime.Object { return &api.PodTemplateList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PodTemplate).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
NewListFunc: func() runtime.Object { return &api.PodTemplateList{} },
PredicateFunc: podtemplate.MatchPodTemplate,
QualifiedResource: api.Resource("podtemplates"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podtemplates"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/replicationcontroller/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ReplicationController).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} },
PredicateFunc: replicationcontroller.MatchController,
QualifiedResource: api.Resource("replicationcontrollers"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicationcontrollers"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/resourcequota/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against resource quotas.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ResourceQuota).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} },
PredicateFunc: resourcequota.MatchResourceQuota,
QualifiedResource: api.Resource("resourcequotas"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("resourcequotas"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/secret/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against secrets.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Secret{} },
NewListFunc: func() runtime.Object { return &api.SecretList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Secret).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Secret{} },
NewListFunc: func() runtime.Object { return &api.SecretList{} },
PredicateFunc: secret.Matcher,
QualifiedResource: api.Resource("secrets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("secrets"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/service/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against services.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Service{} },
NewListFunc: func() runtime.Object { return &api.ServiceList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Service).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.Service{} },
NewListFunc: func() runtime.Object { return &api.ServiceList{} },
PredicateFunc: service.MatchServices,
QualifiedResource: api.Resource("services"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("services"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/core/serviceaccount/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against service accounts.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.ServiceAccount).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
PredicateFunc: serviceaccount.Matcher,
QualifiedResource: api.Resource("serviceaccounts"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("serviceaccounts"),
Expand Down
9 changes: 3 additions & 6 deletions pkg/registry/extensions/daemonset/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against DaemonSets.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
store := &genericregistry.Store{
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*extensions.DaemonSet).Name, nil
},
Copier: api.Scheme,
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} },
PredicateFunc: daemonset.MatchDaemonSet,
QualifiedResource: extensions.Resource("daemonsets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("daemonsets"),
Expand Down