Fix NotFound errors do not line up with API endpoint's group version

pull/6/head
Shiyang Wang 2017-07-19 10:15:21 +08:00
parent c75d3028dd
commit 2eda19da7b
46 changed files with 403 additions and 297 deletions

View File

@ -48,12 +48,12 @@ 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{} },
PredicateFunc: cluster.MatchCluster, PredicateFunc: cluster.MatchCluster,
QualifiedResource: federation.Resource("clusters"), DefaultQualifiedResource: federation.Resource("clusters"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusters"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusters"),
CreateStrategy: cluster.Strategy, CreateStrategy: cluster.Strategy,
UpdateStrategy: cluster.Strategy, UpdateStrategy: cluster.Strategy,

View File

@ -40,9 +40,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
ObjectNameFunc: func(obj runtime.Object) (string, error) { ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*admissionregistration.ExternalAdmissionHookConfiguration).Name, nil return obj.(*admissionregistration.ExternalAdmissionHookConfiguration).Name, nil
}, },
PredicateFunc: externaladmissionhookconfiguration.MatchExternalAdmissionHookConfiguration, PredicateFunc: externaladmissionhookconfiguration.MatchExternalAdmissionHookConfiguration,
QualifiedResource: admissionregistration.Resource("externaladmissionhookconfigurations"), DefaultQualifiedResource: admissionregistration.Resource("externaladmissionhookconfigurations"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("externaladmissionhookconfigurations"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("externaladmissionhookconfigurations"),
CreateStrategy: externaladmissionhookconfiguration.Strategy, CreateStrategy: externaladmissionhookconfiguration.Strategy,
UpdateStrategy: externaladmissionhookconfiguration.Strategy, UpdateStrategy: externaladmissionhookconfiguration.Strategy,

View File

@ -40,9 +40,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
ObjectNameFunc: func(obj runtime.Object) (string, error) { ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*admissionregistration.InitializerConfiguration).Name, nil return obj.(*admissionregistration.InitializerConfiguration).Name, nil
}, },
PredicateFunc: initializerconfiguration.MatchInitializerConfiguration, PredicateFunc: initializerconfiguration.MatchInitializerConfiguration,
QualifiedResource: admissionregistration.Resource("initializerconfigurations"), DefaultQualifiedResource: admissionregistration.Resource("initializerconfigurations"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("initializerconfigurations"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("initializerconfigurations"),
CreateStrategy: initializerconfiguration.Strategy, CreateStrategy: initializerconfiguration.Strategy,
UpdateStrategy: initializerconfiguration.Strategy, UpdateStrategy: initializerconfiguration.Strategy,

View File

@ -34,12 +34,12 @@ type REST struct {
// NewREST returns a RESTStorage object that will work with ControllerRevision objects. // NewREST returns a RESTStorage object that will work with ControllerRevision 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 &apps.ControllerRevision{} }, NewFunc: func() runtime.Object { return &apps.ControllerRevision{} },
NewListFunc: func() runtime.Object { return &apps.ControllerRevisionList{} }, NewListFunc: func() runtime.Object { return &apps.ControllerRevisionList{} },
PredicateFunc: controllerrevision.MatchControllerRevision, PredicateFunc: controllerrevision.MatchControllerRevision,
QualifiedResource: apps.Resource("controllerrevisions"), DefaultQualifiedResource: apps.Resource("controllerrevisions"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("controllerrevisions"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("controllerrevisions"),
CreateStrategy: controllerrevision.Strategy, CreateStrategy: controllerrevision.Strategy,
UpdateStrategy: controllerrevision.Strategy, UpdateStrategy: controllerrevision.Strategy,

View File

@ -37,12 +37,12 @@ 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{} },
PredicateFunc: statefulset.MatchStatefulSet, PredicateFunc: statefulset.MatchStatefulSet,
QualifiedResource: appsapi.Resource("statefulsets"), DefaultQualifiedResource: appsapi.Resource("statefulsets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("statefulsets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("statefulsets"),
CreateStrategy: statefulset.Strategy, CreateStrategy: statefulset.Strategy,
UpdateStrategy: statefulset.Strategy, UpdateStrategy: statefulset.Strategy,

View File

@ -36,12 +36,12 @@ 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{} },
PredicateFunc: horizontalpodautoscaler.MatchAutoscaler, PredicateFunc: horizontalpodautoscaler.MatchAutoscaler,
QualifiedResource: autoscaling.Resource("horizontalpodautoscalers"), DefaultQualifiedResource: autoscaling.Resource("horizontalpodautoscalers"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("horizontalpodautoscalers"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("horizontalpodautoscalers"),
CreateStrategy: horizontalpodautoscaler.Strategy, CreateStrategy: horizontalpodautoscaler.Strategy,
UpdateStrategy: horizontalpodautoscaler.Strategy, UpdateStrategy: horizontalpodautoscaler.Strategy,

View File

@ -37,15 +37,14 @@ 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{} },
QualifiedResource: batch.Resource("cronjobs"), DefaultQualifiedResource: batch.Resource("cronjobs"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("cronjobs"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("cronjobs"),
CreateStrategy: cronjob.Strategy,
CreateStrategy: cronjob.Strategy, UpdateStrategy: cronjob.Strategy,
UpdateStrategy: cronjob.Strategy, DeleteStrategy: cronjob.Strategy,
DeleteStrategy: cronjob.Strategy,
} }
options := &generic.StoreOptions{RESTOptions: optsGetter} options := &generic.StoreOptions{RESTOptions: optsGetter}
if err := store.CompleteWithOptions(options); err != nil { if err := store.CompleteWithOptions(options); err != nil {

View File

@ -52,12 +52,12 @@ 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{} },
PredicateFunc: job.MatchJob, PredicateFunc: job.MatchJob,
QualifiedResource: batch.Resource("jobs"), DefaultQualifiedResource: batch.Resource("jobs"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("jobs"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("jobs"),
CreateStrategy: job.Strategy, CreateStrategy: job.Strategy,
UpdateStrategy: job.Strategy, UpdateStrategy: job.Strategy,

View File

@ -36,12 +36,12 @@ 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{} },
PredicateFunc: csrregistry.Matcher, PredicateFunc: csrregistry.Matcher,
QualifiedResource: certificates.Resource("certificatesigningrequests"), DefaultQualifiedResource: certificates.Resource("certificatesigningrequests"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("certificatesigningrequests"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("certificatesigningrequests"),
CreateStrategy: csrregistry.Strategy, CreateStrategy: csrregistry.Strategy,
UpdateStrategy: csrregistry.Strategy, UpdateStrategy: csrregistry.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: configmap.MatchConfigMap, PredicateFunc: configmap.MatchConfigMap,
QualifiedResource: api.Resource("configmaps"), DefaultQualifiedResource: api.Resource("configmaps"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("configmaps"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("configmaps"),
CreateStrategy: configmap.Strategy, CreateStrategy: configmap.Strategy,
UpdateStrategy: configmap.Strategy, UpdateStrategy: configmap.Strategy,

View File

@ -33,12 +33,12 @@ 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{} },
PredicateFunc: endpoint.MatchEndpoints, PredicateFunc: endpoint.MatchEndpoints,
QualifiedResource: api.Resource("endpoints"), DefaultQualifiedResource: api.Resource("endpoints"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("endpoints"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("endpoints"),
CreateStrategy: endpoint.Strategy, CreateStrategy: endpoint.Strategy,
UpdateStrategy: endpoint.Strategy, UpdateStrategy: endpoint.Strategy,

View File

@ -50,8 +50,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) *REST {
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) { TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
return ttl, nil return ttl, nil
}, },
QualifiedResource: resource, DefaultQualifiedResource: resource,
WatchCacheSize: cachesize.GetWatchCacheSizeByResource(resource.Resource), WatchCacheSize: cachesize.GetWatchCacheSizeByResource(resource.Resource),
CreateStrategy: event.Strategy, CreateStrategy: event.Strategy,
UpdateStrategy: event.Strategy, UpdateStrategy: event.Strategy,

View File

@ -33,12 +33,12 @@ 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{} },
PredicateFunc: limitrange.MatchLimitRange, PredicateFunc: limitrange.MatchLimitRange,
QualifiedResource: api.Resource("limitranges"), DefaultQualifiedResource: api.Resource("limitranges"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("limitranges"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("limitranges"),
CreateStrategy: limitrange.Strategy, CreateStrategy: limitrange.Strategy,
UpdateStrategy: limitrange.Strategy, UpdateStrategy: limitrange.Strategy,

View File

@ -54,12 +54,12 @@ 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{} },
PredicateFunc: namespace.MatchNamespace, PredicateFunc: namespace.MatchNamespace,
QualifiedResource: api.Resource("namespaces"), DefaultQualifiedResource: api.Resource("namespaces"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("namespaces"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("namespaces"),
CreateStrategy: namespace.Strategy, CreateStrategy: namespace.Strategy,
UpdateStrategy: namespace.Strategy, UpdateStrategy: namespace.Strategy,

View File

@ -73,12 +73,12 @@ 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{} },
PredicateFunc: node.MatchNode, PredicateFunc: node.MatchNode,
QualifiedResource: api.Resource("nodes"), DefaultQualifiedResource: api.Resource("nodes"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("nodes"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("nodes"),
CreateStrategy: node.Strategy, CreateStrategy: node.Strategy,
UpdateStrategy: node.Strategy, UpdateStrategy: node.Strategy,

View File

@ -35,12 +35,12 @@ 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{} },
PredicateFunc: persistentvolume.MatchPersistentVolumes, PredicateFunc: persistentvolume.MatchPersistentVolumes,
QualifiedResource: api.Resource("persistentvolumes"), DefaultQualifiedResource: api.Resource("persistentvolumes"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumes"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumes"),
CreateStrategy: persistentvolume.Strategy, CreateStrategy: persistentvolume.Strategy,
UpdateStrategy: persistentvolume.Strategy, UpdateStrategy: persistentvolume.Strategy,

View File

@ -35,12 +35,12 @@ 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{} },
PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim, PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim,
QualifiedResource: api.Resource("persistentvolumeclaims"), DefaultQualifiedResource: api.Resource("persistentvolumeclaims"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumeclaims"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("persistentvolumeclaims"),
CreateStrategy: persistentvolumeclaim.Strategy, CreateStrategy: persistentvolumeclaim.Strategy,
UpdateStrategy: persistentvolumeclaim.Strategy, UpdateStrategy: persistentvolumeclaim.Strategy,

View File

@ -66,12 +66,12 @@ type REST struct {
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{} },
PredicateFunc: pod.MatchPod, PredicateFunc: pod.MatchPod,
QualifiedResource: api.Resource("pods"), DefaultQualifiedResource: api.Resource("pods"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("pods"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("pods"),
CreateStrategy: pod.Strategy, CreateStrategy: pod.Strategy,
UpdateStrategy: pod.Strategy, UpdateStrategy: pod.Strategy,

View File

@ -32,12 +32,12 @@ 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{} },
PredicateFunc: podtemplate.MatchPodTemplate, PredicateFunc: podtemplate.MatchPodTemplate,
QualifiedResource: api.Resource("podtemplates"), DefaultQualifiedResource: api.Resource("podtemplates"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podtemplates"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podtemplates"),
CreateStrategy: podtemplate.Strategy, CreateStrategy: podtemplate.Strategy,
UpdateStrategy: podtemplate.Strategy, UpdateStrategy: podtemplate.Strategy,

View File

@ -61,12 +61,12 @@ 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{} },
PredicateFunc: replicationcontroller.MatchController, PredicateFunc: replicationcontroller.MatchController,
QualifiedResource: api.Resource("replicationcontrollers"), DefaultQualifiedResource: api.Resource("replicationcontrollers"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicationcontrollers"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicationcontrollers"),
CreateStrategy: replicationcontroller.Strategy, CreateStrategy: replicationcontroller.Strategy,
UpdateStrategy: replicationcontroller.Strategy, UpdateStrategy: replicationcontroller.Strategy,

View File

@ -35,12 +35,12 @@ 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{} },
PredicateFunc: resourcequota.MatchResourceQuota, PredicateFunc: resourcequota.MatchResourceQuota,
QualifiedResource: api.Resource("resourcequotas"), DefaultQualifiedResource: api.Resource("resourcequotas"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("resourcequotas"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("resourcequotas"),
CreateStrategy: resourcequota.Strategy, CreateStrategy: resourcequota.Strategy,
UpdateStrategy: resourcequota.Strategy, UpdateStrategy: resourcequota.Strategy,

View File

@ -32,12 +32,12 @@ 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{} },
PredicateFunc: secret.Matcher, PredicateFunc: secret.Matcher,
QualifiedResource: api.Resource("secrets"), DefaultQualifiedResource: api.Resource("secrets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("secrets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("secrets"),
CreateStrategy: secret.Strategy, CreateStrategy: secret.Strategy,
UpdateStrategy: secret.Strategy, UpdateStrategy: secret.Strategy,

View File

@ -35,12 +35,12 @@ 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{} },
PredicateFunc: service.MatchServices, PredicateFunc: service.MatchServices,
QualifiedResource: api.Resource("services"), DefaultQualifiedResource: api.Resource("services"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("services"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("services"),
CreateStrategy: service.Strategy, CreateStrategy: service.Strategy,
UpdateStrategy: service.Strategy, UpdateStrategy: service.Strategy,

View File

@ -33,12 +33,12 @@ 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{} },
PredicateFunc: serviceaccount.Matcher, PredicateFunc: serviceaccount.Matcher,
QualifiedResource: api.Resource("serviceaccounts"), DefaultQualifiedResource: api.Resource("serviceaccounts"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("serviceaccounts"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("serviceaccounts"),
CreateStrategy: serviceaccount.Strategy, CreateStrategy: serviceaccount.Strategy,
UpdateStrategy: serviceaccount.Strategy, UpdateStrategy: serviceaccount.Strategy,

View File

@ -37,12 +37,12 @@ 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{} },
PredicateFunc: daemonset.MatchDaemonSet, PredicateFunc: daemonset.MatchDaemonSet,
QualifiedResource: extensions.Resource("daemonsets"), DefaultQualifiedResource: extensions.Resource("daemonsets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("daemonsets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("daemonsets"),
CreateStrategy: daemonset.Strategy, CreateStrategy: daemonset.Strategy,
UpdateStrategy: daemonset.Strategy, UpdateStrategy: daemonset.Strategy,

View File

@ -63,12 +63,12 @@ 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{} },
PredicateFunc: deployment.MatchDeployment, PredicateFunc: deployment.MatchDeployment,
QualifiedResource: extensions.Resource("deployments"), DefaultQualifiedResource: extensions.Resource("deployments"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("deployments"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("deployments"),
CreateStrategy: deployment.Strategy, CreateStrategy: deployment.Strategy,
UpdateStrategy: deployment.Strategy, UpdateStrategy: deployment.Strategy,

View File

@ -37,12 +37,12 @@ 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{} },
PredicateFunc: ingress.MatchIngress, PredicateFunc: ingress.MatchIngress,
QualifiedResource: extensions.Resource("ingresses"), DefaultQualifiedResource: extensions.Resource("ingresses"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("ingresses"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("ingresses"),
CreateStrategy: ingress.Strategy, CreateStrategy: ingress.Strategy,
UpdateStrategy: ingress.Strategy, UpdateStrategy: ingress.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: networkpolicy.MatchNetworkPolicy, PredicateFunc: networkpolicy.MatchNetworkPolicy,
QualifiedResource: extensionsapi.Resource("networkpolicies"), DefaultQualifiedResource: extensionsapi.Resource("networkpolicies"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("networkpolicies"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("networkpolicies"),
CreateStrategy: networkpolicy.Strategy, CreateStrategy: networkpolicy.Strategy,
UpdateStrategy: networkpolicy.Strategy, UpdateStrategy: networkpolicy.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: podsecuritypolicy.MatchPodSecurityPolicy, PredicateFunc: podsecuritypolicy.MatchPodSecurityPolicy,
QualifiedResource: extensions.Resource("podsecuritypolicies"), DefaultQualifiedResource: extensions.Resource("podsecuritypolicies"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podsecuritypolicies"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podsecuritypolicies"),
CreateStrategy: podsecuritypolicy.Strategy, CreateStrategy: podsecuritypolicy.Strategy,
UpdateStrategy: podsecuritypolicy.Strategy, UpdateStrategy: podsecuritypolicy.Strategy,

View File

@ -60,12 +60,12 @@ 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{} },
PredicateFunc: replicaset.MatchReplicaSet, PredicateFunc: replicaset.MatchReplicaSet,
QualifiedResource: extensions.Resource("replicasets"), DefaultQualifiedResource: extensions.Resource("replicasets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicasets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("replicasets"),
CreateStrategy: replicaset.Strategy, CreateStrategy: replicaset.Strategy,
UpdateStrategy: replicaset.Strategy, UpdateStrategy: replicaset.Strategy,

View File

@ -35,12 +35,12 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against NetworkPolicies // NewREST returns a RESTStorage object that will work against NetworkPolicies
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 &networkingapi.NetworkPolicy{} }, NewFunc: func() runtime.Object { return &networkingapi.NetworkPolicy{} },
NewListFunc: func() runtime.Object { return &networkingapi.NetworkPolicyList{} }, NewListFunc: func() runtime.Object { return &networkingapi.NetworkPolicyList{} },
PredicateFunc: networkpolicy.Matcher, PredicateFunc: networkpolicy.Matcher,
QualifiedResource: networkingapi.Resource("networkpolicies"), DefaultQualifiedResource: networkingapi.Resource("networkpolicies"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("networkpolicies"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("networkpolicies"),
CreateStrategy: networkpolicy.Strategy, CreateStrategy: networkpolicy.Strategy,
UpdateStrategy: networkpolicy.Strategy, UpdateStrategy: networkpolicy.Strategy,

View File

@ -37,12 +37,12 @@ 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{} },
PredicateFunc: poddisruptionbudget.MatchPodDisruptionBudget, PredicateFunc: poddisruptionbudget.MatchPodDisruptionBudget,
QualifiedResource: policyapi.Resource("poddisruptionbudgets"), DefaultQualifiedResource: policyapi.Resource("poddisruptionbudgets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("poddisruptionbudgets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("poddisruptionbudgets"),
CreateStrategy: poddisruptionbudget.Strategy, CreateStrategy: poddisruptionbudget.Strategy,
UpdateStrategy: poddisruptionbudget.Strategy, UpdateStrategy: poddisruptionbudget.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: clusterrole.Matcher, PredicateFunc: clusterrole.Matcher,
QualifiedResource: rbac.Resource("clusterroles"), DefaultQualifiedResource: rbac.Resource("clusterroles"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterroles"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterroles"),
CreateStrategy: clusterrole.Strategy, CreateStrategy: clusterrole.Strategy,
UpdateStrategy: clusterrole.Strategy, UpdateStrategy: clusterrole.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: clusterrolebinding.Matcher, PredicateFunc: clusterrolebinding.Matcher,
QualifiedResource: rbac.Resource("clusterrolebindings"), DefaultQualifiedResource: rbac.Resource("clusterrolebindings"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterrolebindings"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("clusterrolebindings"),
CreateStrategy: clusterrolebinding.Strategy, CreateStrategy: clusterrolebinding.Strategy,
UpdateStrategy: clusterrolebinding.Strategy, UpdateStrategy: clusterrolebinding.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: role.Matcher, PredicateFunc: role.Matcher,
QualifiedResource: rbac.Resource("roles"), DefaultQualifiedResource: rbac.Resource("roles"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("roles"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("roles"),
CreateStrategy: role.Strategy, CreateStrategy: role.Strategy,
UpdateStrategy: role.Strategy, UpdateStrategy: role.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: rolebinding.Matcher, PredicateFunc: rolebinding.Matcher,
QualifiedResource: rbac.Resource("rolebindings"), DefaultQualifiedResource: rbac.Resource("rolebindings"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("rolebindings"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("rolebindings"),
CreateStrategy: rolebinding.Strategy, CreateStrategy: rolebinding.Strategy,
UpdateStrategy: rolebinding.Strategy, UpdateStrategy: rolebinding.Strategy,

View File

@ -35,12 +35,12 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against priority classes. // NewREST returns a RESTStorage object that will work against priority classes.
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 &schedulingapi.PriorityClass{} }, NewFunc: func() runtime.Object { return &schedulingapi.PriorityClass{} },
NewListFunc: func() runtime.Object { return &schedulingapi.PriorityClassList{} }, NewListFunc: func() runtime.Object { return &schedulingapi.PriorityClassList{} },
PredicateFunc: priorityclass.Matcher, PredicateFunc: priorityclass.Matcher,
QualifiedResource: schedulingapi.Resource("priorityclasses"), DefaultQualifiedResource: schedulingapi.Resource("priorityclasses"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("priorityclasses"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("priorityclasses"),
CreateStrategy: priorityclass.Strategy, CreateStrategy: priorityclass.Strategy,
UpdateStrategy: priorityclass.Strategy, UpdateStrategy: priorityclass.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: podpreset.Matcher, PredicateFunc: podpreset.Matcher,
QualifiedResource: settingsapi.Resource("podpresets"), DefaultQualifiedResource: settingsapi.Resource("podpresets"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podpresets"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("podpresets"),
CreateStrategy: podpreset.Strategy, CreateStrategy: podpreset.Strategy,
UpdateStrategy: podpreset.Strategy, UpdateStrategy: podpreset.Strategy,

View File

@ -34,12 +34,12 @@ 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{} },
PredicateFunc: storageclass.MatchStorageClasses, PredicateFunc: storageclass.MatchStorageClasses,
QualifiedResource: storageapi.Resource("storageclasses"), DefaultQualifiedResource: storageapi.Resource("storageclasses"),
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("storageclass"), WatchCacheSize: cachesize.GetWatchCacheSizeByResource("storageclass"),
CreateStrategy: storageclass.Strategy, CreateStrategy: storageclass.Strategy,
UpdateStrategy: storageclass.Strategy, UpdateStrategy: storageclass.Strategy,

View File

@ -40,8 +40,8 @@ func NewREST(resource schema.GroupResource, listKind schema.GroupVersionKind, co
ret.SetGroupVersionKind(listKind) ret.SetGroupVersionKind(listKind)
return ret return ret
}, },
PredicateFunc: strategy.MatchCustomResourceDefinitionStorage, PredicateFunc: strategy.MatchCustomResourceDefinitionStorage,
QualifiedResource: resource, DefaultQualifiedResource: resource,
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,

View File

@ -41,11 +41,11 @@ 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 &apiextensions.CustomResourceDefinition{} }, NewFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinition{} },
NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinitionList{} }, NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinitionList{} },
PredicateFunc: MatchCustomResourceDefinition, PredicateFunc: MatchCustomResourceDefinition,
QualifiedResource: apiextensions.Resource("customresourcedefinitions"), DefaultQualifiedResource: apiextensions.Resource("customresourcedefinitions"),
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,

View File

@ -37,6 +37,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/endpoints/request"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
@ -82,8 +83,10 @@ type Store struct {
// curl GET /apis/group/version/namespaces/my-ns/myresource // curl GET /apis/group/version/namespaces/my-ns/myresource
NewListFunc func() runtime.Object NewListFunc func() runtime.Object
// QualifiedResource is the pluralized name of the resource. // DefaultQualifiedResource is the pluralized name of the resource.
QualifiedResource schema.GroupResource // This field is used if there is no request info present in the context.
// See qualifiedResourceFromContext for details.
DefaultQualifiedResource schema.GroupResource
// KeyRootFunc returns the root etcd key for this resource; should not // KeyRootFunc returns the root etcd key for this resource; should not
// include trailing "/". This is used for operations that work on the // include trailing "/". This is used for operations that work on the
@ -262,16 +265,17 @@ func (e *Store) ListPredicate(ctx genericapirequest.Context, p storage.Selection
} }
p.IncludeUninitialized = options.IncludeUninitialized p.IncludeUninitialized = options.IncludeUninitialized
list := e.NewListFunc() list := e.NewListFunc()
qualifiedResource := e.qualifiedResourceFromContext(ctx)
if name, ok := p.MatchesSingle(); ok { if name, ok := p.MatchesSingle(); ok {
if key, err := e.KeyFunc(ctx, name); err == nil { if key, err := e.KeyFunc(ctx, name); err == nil {
err := e.Storage.GetToList(ctx, key, options.ResourceVersion, p, list) err := e.Storage.GetToList(ctx, key, options.ResourceVersion, p, list)
return list, storeerr.InterpretListError(err, e.QualifiedResource) return list, storeerr.InterpretListError(err, qualifiedResource)
} }
// if we cannot extract a key based on the current context, the optimization is skipped // if we cannot extract a key based on the current context, the optimization is skipped
} }
err := e.Storage.List(ctx, e.KeyRootFunc(ctx), options.ResourceVersion, p, list) err := e.Storage.List(ctx, e.KeyRootFunc(ctx), options.ResourceVersion, p, list)
return list, storeerr.InterpretListError(err, e.QualifiedResource) return list, storeerr.InterpretListError(err, qualifiedResource)
} }
// Create inserts a new item according to the unique key from the object. // Create inserts a new item according to the unique key from the object.
@ -287,13 +291,14 @@ func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, includ
if err != nil { if err != nil {
return nil, err return nil, err
} }
qualifiedResource := e.qualifiedResourceFromContext(ctx)
ttl, err := e.calculateTTL(obj, 0, false) ttl, err := e.calculateTTL(obj, 0, false)
if err != nil { if err != nil {
return nil, err return nil, err
} }
out := e.NewFunc() out := e.NewFunc()
if err := e.Storage.Create(ctx, key, obj, out, ttl); err != nil { if err := e.Storage.Create(ctx, key, obj, out, ttl); err != nil {
err = storeerr.InterpretCreateError(err, e.QualifiedResource, name) err = storeerr.InterpretCreateError(err, qualifiedResource, name)
err = rest.CheckGeneratedNameError(e.CreateStrategy, err, obj) err = rest.CheckGeneratedNameError(e.CreateStrategy, err, obj)
if !kubeerr.IsAlreadyExists(err) { if !kubeerr.IsAlreadyExists(err) {
return nil, err return nil, err
@ -327,6 +332,8 @@ func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, includ
return out, nil return out, nil
} }
// WaitForInitialized holds until the object is initialized, or returns an error if the default limit expires.
// This method is exposed publicly for consumers of generic rest tooling.
func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) { func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) {
// return early if we don't have initializers, or if they've completed already // return early if we don't have initializers, or if they've completed already
accessor, err := meta.Accessor(obj) accessor, err := meta.Accessor(obj)
@ -345,6 +352,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob
if err != nil { if err != nil {
return nil, err return nil, err
} }
qualifiedResource := e.qualifiedResourceFromContext(ctx)
w, err := e.Storage.Watch(ctx, key, accessor.GetResourceVersion(), storage.SelectionPredicate{ w, err := e.Storage.Watch(ctx, key, accessor.GetResourceVersion(), storage.SelectionPredicate{
Label: labels.Everything(), Label: labels.Everything(),
Field: fields.Everything(), Field: fields.Everything(),
@ -363,7 +371,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob
case event, ok := <-ch: case event, ok := <-ch:
if !ok { if !ok {
msg := fmt.Sprintf("server has timed out waiting for the initialization of %s %s", msg := fmt.Sprintf("server has timed out waiting for the initialization of %s %s",
e.QualifiedResource.String(), accessor.GetName()) qualifiedResource.String(), accessor.GetName())
return nil, kubeerr.NewTimeoutError(msg, 0) return nil, kubeerr.NewTimeoutError(msg, 0)
} }
switch event.Type { switch event.Type {
@ -448,15 +456,15 @@ func (e *Store) deleteWithoutFinalizers(ctx genericapirequest.Context, name, key
// requests to remove all finalizers from the object, so we // requests to remove all finalizers from the object, so we
// ignore the NotFound error. // ignore the NotFound error.
if storage.IsNotFound(err) { if storage.IsNotFound(err) {
_, err := e.finalizeDelete(obj, true) _, err := e.finalizeDelete(ctx, obj, true)
// clients are expecting an updated object if a PUT succeeded, // clients are expecting an updated object if a PUT succeeded,
// but finalizeDelete returns a metav1.Status, so return // but finalizeDelete returns a metav1.Status, so return
// the object in the request instead. // the object in the request instead.
return obj, false, err return obj, false, err
} }
return nil, false, storeerr.InterpretDeleteError(err, e.QualifiedResource, name) return nil, false, storeerr.InterpretDeleteError(err, e.qualifiedResourceFromContext(ctx), name)
} }
_, err := e.finalizeDelete(out, true) _, err := e.finalizeDelete(ctx, out, true)
// clients are expecting an updated object if a PUT succeeded, but // clients are expecting an updated object if a PUT succeeded, but
// finalizeDelete returns a metav1.Status, so return the object in // finalizeDelete returns a metav1.Status, so return the object in
// the request instead. // the request instead.
@ -477,6 +485,7 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
creating = false creating = false
) )
qualifiedResource := e.qualifiedResourceFromContext(ctx)
storagePreconditions := &storage.Preconditions{} storagePreconditions := &storage.Preconditions{}
if preconditions := objInfo.Preconditions(); preconditions != nil { if preconditions := objInfo.Preconditions(); preconditions != nil {
storagePreconditions.UID = preconditions.UID storagePreconditions.UID = preconditions.UID
@ -508,7 +517,7 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
} }
if version == 0 { if version == 0 {
if !e.UpdateStrategy.AllowCreateOnUpdate() { if !e.UpdateStrategy.AllowCreateOnUpdate() {
return nil, nil, kubeerr.NewNotFound(e.QualifiedResource, name) return nil, nil, kubeerr.NewNotFound(qualifiedResource, name)
} }
creating = true creating = true
creatingObj = obj creatingObj = obj
@ -542,12 +551,12 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
// TODO: The Invalid error should have a field for Resource. // TODO: The Invalid error should have a field for Resource.
// After that field is added, we should fill the Resource and // After that field is added, we should fill the Resource and
// leave the Kind field empty. See the discussion in #18526. // leave the Kind field empty. See the discussion in #18526.
qualifiedKind := schema.GroupKind{Group: e.QualifiedResource.Group, Kind: e.QualifiedResource.Resource} qualifiedKind := schema.GroupKind{Group: qualifiedResource.Group, Kind: qualifiedResource.Resource}
fieldErrList := field.ErrorList{field.Invalid(field.NewPath("metadata").Child("resourceVersion"), newVersion, "must be specified for an update")} fieldErrList := field.ErrorList{field.Invalid(field.NewPath("metadata").Child("resourceVersion"), newVersion, "must be specified for an update")}
return nil, nil, kubeerr.NewInvalid(qualifiedKind, name, fieldErrList) return nil, nil, kubeerr.NewInvalid(qualifiedKind, name, fieldErrList)
} }
if newVersion != version { if newVersion != version {
return nil, nil, kubeerr.NewConflict(e.QualifiedResource, name, fmt.Errorf(OptimisticLockErrorMsg)) return nil, nil, kubeerr.NewConflict(qualifiedResource, name, fmt.Errorf(OptimisticLockErrorMsg))
} }
} }
if err := rest.BeforeUpdate(e.UpdateStrategy, ctx, obj, existing); err != nil { if err := rest.BeforeUpdate(e.UpdateStrategy, ctx, obj, existing); err != nil {
@ -573,10 +582,10 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
return e.deleteWithoutFinalizers(ctx, name, key, deleteObj, storagePreconditions) return e.deleteWithoutFinalizers(ctx, name, key, deleteObj, storagePreconditions)
} }
if creating { if creating {
err = storeerr.InterpretCreateError(err, e.QualifiedResource, name) err = storeerr.InterpretCreateError(err, qualifiedResource, name)
err = rest.CheckGeneratedNameError(e.CreateStrategy, err, creatingObj) err = rest.CheckGeneratedNameError(e.CreateStrategy, err, creatingObj)
} else { } else {
err = storeerr.InterpretUpdateError(err, e.QualifiedResource, name) err = storeerr.InterpretUpdateError(err, qualifiedResource, name)
} }
return nil, false, err return nil, false, err
} }
@ -614,7 +623,7 @@ func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1.
return nil, err return nil, err
} }
if err := e.Storage.Get(ctx, key, options.ResourceVersion, obj, false); err != nil { if err := e.Storage.Get(ctx, key, options.ResourceVersion, obj, false); err != nil {
return nil, storeerr.InterpretGetError(err, e.QualifiedResource, name) return nil, storeerr.InterpretGetError(err, e.qualifiedResourceFromContext(ctx), name)
} }
if e.Decorator != nil { if e.Decorator != nil {
if err := e.Decorator(obj); err != nil { if err := e.Decorator(obj); err != nil {
@ -624,6 +633,16 @@ func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1.
return obj, nil return obj, nil
} }
// qualifiedResourceFromContext attempts to retrieve a GroupResource from the context's request info.
// If the context has no request info, DefaultQualifiedResource is used.
func (e *Store) qualifiedResourceFromContext(ctx genericapirequest.Context) schema.GroupResource {
if info, ok := request.RequestInfoFrom(ctx); ok {
return schema.GroupResource{Group: info.APIGroup, Resource: info.Resource}
}
// some implementations access storage directly and thus the context has no RequestInfo
return e.DefaultQualifiedResource
}
var ( var (
errAlreadyDeleting = fmt.Errorf("abort delete") errAlreadyDeleting = fmt.Errorf("abort delete")
errDeleteNow = fmt.Errorf("delete now") errDeleteNow = fmt.Errorf("delete now")
@ -827,10 +846,10 @@ func (e *Store) updateForGracefulDeletion(ctx genericapirequest.Context, name, k
// we should fall through and truly delete the object. // we should fall through and truly delete the object.
return nil, false, true, out, lastExisting return nil, false, true, out, lastExisting
case errAlreadyDeleting: case errAlreadyDeleting:
out, err = e.finalizeDelete(in, true) out, err = e.finalizeDelete(ctx, in, true)
return err, false, false, out, lastExisting return err, false, false, out, lastExisting
default: default:
return storeerr.InterpretUpdateError(err, e.QualifiedResource, name), false, false, out, lastExisting return storeerr.InterpretUpdateError(err, e.qualifiedResourceFromContext(ctx), name), false, false, out, lastExisting
} }
} }
@ -918,10 +937,10 @@ func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Con
// we should fall through and truly delete the object. // we should fall through and truly delete the object.
return nil, false, true, out, lastExisting return nil, false, true, out, lastExisting
case errAlreadyDeleting: case errAlreadyDeleting:
out, err = e.finalizeDelete(in, true) out, err = e.finalizeDelete(ctx, in, true)
return err, false, false, out, lastExisting return err, false, false, out, lastExisting
default: default:
return storeerr.InterpretUpdateError(err, e.QualifiedResource, name), false, false, out, lastExisting return storeerr.InterpretUpdateError(err, e.qualifiedResourceFromContext(ctx), name), false, false, out, lastExisting
} }
} }
@ -931,10 +950,10 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta
if err != nil { if err != nil {
return nil, false, err return nil, false, err
} }
obj := e.NewFunc() obj := e.NewFunc()
qualifiedResource := e.qualifiedResourceFromContext(ctx)
if err := e.Storage.Get(ctx, key, "", obj, false); err != nil { if err := e.Storage.Get(ctx, key, "", obj, false); err != nil {
return nil, false, storeerr.InterpretDeleteError(err, e.QualifiedResource, name) return nil, false, storeerr.InterpretDeleteError(err, qualifiedResource, name)
} }
// support older consumers of delete by treating "nil" as delete immediately // support older consumers of delete by treating "nil" as delete immediately
if options == nil { if options == nil {
@ -950,7 +969,7 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta
} }
// this means finalizers cannot be updated via DeleteOptions if a deletion is already pending // this means finalizers cannot be updated via DeleteOptions if a deletion is already pending
if pendingGraceful { if pendingGraceful {
out, err := e.finalizeDelete(obj, false) out, err := e.finalizeDelete(ctx, obj, false)
return out, false, err return out, false, err
} }
// check if obj has pending finalizers // check if obj has pending finalizers
@ -991,12 +1010,12 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta
if storage.IsNotFound(err) && ignoreNotFound && lastExisting != nil { if storage.IsNotFound(err) && ignoreNotFound && lastExisting != nil {
// The lastExisting object may not be the last state of the object // The lastExisting object may not be the last state of the object
// before its deletion, but it's the best approximation. // before its deletion, but it's the best approximation.
out, err := e.finalizeDelete(lastExisting, true) out, err := e.finalizeDelete(ctx, lastExisting, true)
return out, true, err return out, true, err
} }
return nil, false, storeerr.InterpretDeleteError(err, e.QualifiedResource, name) return nil, false, storeerr.InterpretDeleteError(err, qualifiedResource, name)
} }
out, err = e.finalizeDelete(out, true) out, err = e.finalizeDelete(ctx, out, true)
return out, true, err return out, true, err
} }
@ -1098,7 +1117,7 @@ func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.
// finalizeDelete runs the Store's AfterDelete hook if runHooks is set and // finalizeDelete runs the Store's AfterDelete hook if runHooks is set and
// returns the decorated deleted object if appropriate. // returns the decorated deleted object if appropriate.
func (e *Store) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Object, error) { func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) {
if runHooks && e.AfterDelete != nil { if runHooks && e.AfterDelete != nil {
if err := e.AfterDelete(obj); err != nil { if err := e.AfterDelete(obj); err != nil {
return nil, err return nil, err
@ -1118,10 +1137,11 @@ func (e *Store) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Objec
if err != nil { if err != nil {
return nil, err return nil, err
} }
qualifiedResource := e.qualifiedResourceFromContext(ctx)
details := &metav1.StatusDetails{ details := &metav1.StatusDetails{
Name: accessor.GetName(), Name: accessor.GetName(),
Group: e.QualifiedResource.Group, Group: qualifiedResource.Group,
Kind: e.QualifiedResource.Resource, // Yes we set Kind field to resource. Kind: qualifiedResource.Resource, // Yes we set Kind field to resource.
UID: accessor.GetUID(), UID: accessor.GetUID(),
} }
status := &metav1.Status{Status: metav1.StatusSuccess, Details: details} status := &metav1.Status{Status: metav1.StatusSuccess, Details: details}
@ -1238,17 +1258,17 @@ func (e *Store) Export(ctx genericapirequest.Context, name string, opts metav1.E
// CompleteWithOptions updates the store with the provided options and // CompleteWithOptions updates the store with the provided options and
// defaults common fields. // defaults common fields.
func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error { func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
if e.QualifiedResource.Empty() { if e.DefaultQualifiedResource.Empty() {
return fmt.Errorf("store %#v must have a non-empty qualified resource", e) return fmt.Errorf("store %#v must have a non-empty qualified resource", e)
} }
if e.NewFunc == nil { if e.NewFunc == nil {
return fmt.Errorf("store for %s must have NewFunc set", e.QualifiedResource.String()) return fmt.Errorf("store for %s must have NewFunc set", e.DefaultQualifiedResource.String())
} }
if e.NewListFunc == nil { if e.NewListFunc == nil {
return fmt.Errorf("store for %s must have NewListFunc set", e.QualifiedResource.String()) return fmt.Errorf("store for %s must have NewListFunc set", e.DefaultQualifiedResource.String())
} }
if (e.KeyRootFunc == nil) != (e.KeyFunc == nil) { if (e.KeyRootFunc == nil) != (e.KeyFunc == nil) {
return fmt.Errorf("store for %s must set both KeyRootFunc and KeyFunc or neither", e.QualifiedResource.String()) return fmt.Errorf("store for %s must set both KeyRootFunc and KeyFunc or neither", e.DefaultQualifiedResource.String())
} }
var isNamespaced bool var isNamespaced bool
@ -1258,15 +1278,15 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
case e.UpdateStrategy != nil: case e.UpdateStrategy != nil:
isNamespaced = e.UpdateStrategy.NamespaceScoped() isNamespaced = e.UpdateStrategy.NamespaceScoped()
default: default:
return fmt.Errorf("store for %s must have CreateStrategy or UpdateStrategy set", e.QualifiedResource.String()) return fmt.Errorf("store for %s must have CreateStrategy or UpdateStrategy set", e.DefaultQualifiedResource.String())
} }
if e.DeleteStrategy == nil { if e.DeleteStrategy == nil {
return fmt.Errorf("store for %s must have DeleteStrategy set", e.QualifiedResource.String()) return fmt.Errorf("store for %s must have DeleteStrategy set", e.DefaultQualifiedResource.String())
} }
if options.RESTOptions == nil { if options.RESTOptions == nil {
return fmt.Errorf("options for %s must have RESTOptions set", e.QualifiedResource.String()) return fmt.Errorf("options for %s must have RESTOptions set", e.DefaultQualifiedResource.String())
} }
attrFunc := options.AttrFunc attrFunc := options.AttrFunc
@ -1287,7 +1307,7 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
} }
} }
opts, err := options.RESTOptions.GetRESTOptions(e.QualifiedResource) opts, err := options.RESTOptions.GetRESTOptions(e.DefaultQualifiedResource)
if err != nil { if err != nil {
return err return err
} }
@ -1298,7 +1318,7 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
prefix = "/" + prefix prefix = "/" + prefix
} }
if prefix == "/" { if prefix == "/" {
return fmt.Errorf("store for %s has an invalid prefix %q", e.QualifiedResource.String(), opts.ResourcePrefix) return fmt.Errorf("store for %s has an invalid prefix %q", e.DefaultQualifiedResource.String(), opts.ResourcePrefix)
} }
// Set the default behavior for storage key generation // Set the default behavior for storage key generation
@ -1377,5 +1397,5 @@ func (e *Store) ConvertToTable(ctx genericapirequest.Context, object runtime.Obj
if e.TableConvertor != nil { if e.TableConvertor != nil {
return e.TableConvertor.ConvertToTable(ctx, object, tableOptions) return e.TableConvertor.ConvertToTable(ctx, object, tableOptions)
} }
return rest.NewDefaultTableConvertor(e.QualifiedResource).ConvertToTable(ctx, object, tableOptions) return rest.NewDefaultTableConvertor(e.qualifiedResourceFromContext(ctx)).ConvertToTable(ctx, object, tableOptions)
} }

View File

@ -42,6 +42,7 @@ import (
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/apis/example" "k8s.io/apiserver/pkg/apis/example"
examplev1 "k8s.io/apiserver/pkg/apis/example/v1" examplev1 "k8s.io/apiserver/pkg/apis/example/v1"
"k8s.io/apiserver/pkg/endpoints/request"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
@ -381,6 +382,13 @@ func isInitialized(obj metav1.Object) bool {
return obj.GetInitializers() == nil return obj.GetInitializers() == nil
} }
func isQualifiedResource(err error, kind, group string) bool {
if err.(errors.APIStatus).Status().Details.Kind != kind || err.(errors.APIStatus).Status().Details.Group != group {
return false
}
return true
}
func TestStoreCreateInitialized(t *testing.T) { func TestStoreCreateInitialized(t *testing.T) {
podA := &example.Pod{ podA := &example.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -1801,13 +1809,13 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE
} }
return destroyFunc, &Store{ return destroyFunc, &Store{
Copier: scheme, Copier: scheme,
NewFunc: func() runtime.Object { return &example.Pod{} }, NewFunc: func() runtime.Object { return &example.Pod{} },
NewListFunc: func() runtime.Object { return &example.PodList{} }, NewListFunc: func() runtime.Object { return &example.PodList{} },
QualifiedResource: example.Resource("pods"), DefaultQualifiedResource: example.Resource("pods"),
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,
DeleteStrategy: strategy, DeleteStrategy: strategy,
KeyRootFunc: func(ctx genericapirequest.Context) string { KeyRootFunc: func(ctx genericapirequest.Context) string {
return podPrefix return podPrefix
}, },
@ -1842,7 +1850,7 @@ func TestFinalizeDelete(t *testing.T) {
obj := &example.Pod{ obj := &example.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "random-uid"}, ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "random-uid"},
} }
result, err := s.finalizeDelete(obj, false) result, err := s.finalizeDelete(genericapirequest.NewContext(), obj, false)
if err != nil { if err != nil {
t.Fatalf("unexpected err: %s", err) t.Fatalf("unexpected err: %s", err)
} }
@ -1852,8 +1860,8 @@ func TestFinalizeDelete(t *testing.T) {
Status: metav1.StatusSuccess, Status: metav1.StatusSuccess,
Details: &metav1.StatusDetails{ Details: &metav1.StatusDetails{
Name: "foo", Name: "foo",
Group: s.QualifiedResource.Group, Group: s.DefaultQualifiedResource.Group,
Kind: s.QualifiedResource.Resource, Kind: s.DefaultQualifiedResource.Resource,
UID: "random-uid", UID: "random-uid",
}, },
} }
@ -1861,3 +1869,82 @@ func TestFinalizeDelete(t *testing.T) {
t.Errorf("unexpected obj. expected %#v, got %#v", expectedObj, returnedObj) t.Errorf("unexpected obj. expected %#v, got %#v", expectedObj, returnedObj)
} }
} }
func fakeRequestInfo(resource, apiGroup string) *request.RequestInfo {
return &request.RequestInfo{
IsResourceRequest: true,
Path: "/api/v1/test",
Verb: "test",
APIPrefix: "api",
APIGroup: apiGroup,
APIVersion: "v1",
Namespace: "",
Resource: resource,
Subresource: "",
Name: "",
Parts: []string{"test"},
}
}
func TestQualifiedResource(t *testing.T) {
podA := &example.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "test"},
Spec: example.PodSpec{NodeName: "machine"},
}
qualifiedKind := "pod"
qualifiedGroup := "test"
testContext := genericapirequest.WithNamespace(genericapirequest.NewContext(), "test")
testContext = genericapirequest.WithRequestInfo(testContext, fakeRequestInfo(qualifiedKind, qualifiedGroup))
destroyFunc, registry := NewTestGenericStoreRegistry(t)
defer destroyFunc()
// update a non-exist object
_, _, err := registry.Update(testContext, podA.Name, rest.DefaultUpdatedObjectInfo(podA, scheme))
if !errors.IsNotFound(err) {
t.Fatalf("Unexpected error: %v", err)
}
if !isQualifiedResource(err, qualifiedKind, qualifiedGroup) {
t.Fatalf("Unexpected error: %#v", err)
}
// get a non-exist object
_, err = registry.Get(testContext, podA.Name, &metav1.GetOptions{})
if !errors.IsNotFound(err) {
t.Fatalf("Unexpected error: %v", err)
}
if !isQualifiedResource(err, qualifiedKind, qualifiedGroup) {
t.Fatalf("Unexpected error: %#v", err)
}
// delete a non-exist object
_, _, err = registry.Delete(testContext, podA.Name, nil)
if !errors.IsNotFound(err) {
t.Fatalf("Unexpected error: %v", err)
}
if !isQualifiedResource(err, qualifiedKind, qualifiedGroup) {
t.Fatalf("Unexpected error: %#v", err)
}
// create a non-exist object
_, err = registry.Create(testContext, podA, false)
if err != nil {
t.Fatal(err)
}
// create a exist object will fail
_, err = registry.Create(testContext, podA, false)
if !errors.IsAlreadyExists(err) {
t.Fatalf("Unexpected error: %v", err)
}
if !isQualifiedResource(err, qualifiedKind, qualifiedGroup) {
t.Fatalf("Unexpected error: %#v", err)
}
}

View File

@ -35,11 +35,11 @@ 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{} },
PredicateFunc: apiservice.MatchAPIService, PredicateFunc: apiservice.MatchAPIService,
QualifiedResource: apiregistration.Resource("apiservices"), DefaultQualifiedResource: apiregistration.Resource("apiservices"),
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,

View File

@ -29,11 +29,11 @@ func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*reg
strategy := NewStrategy(scheme) strategy := NewStrategy(scheme)
store := &genericregistry.Store{ store := &genericregistry.Store{
Copier: scheme, Copier: scheme,
NewFunc: func() runtime.Object { return &wardle.Fischer{} }, NewFunc: func() runtime.Object { return &wardle.Fischer{} },
NewListFunc: func() runtime.Object { return &wardle.FischerList{} }, NewListFunc: func() runtime.Object { return &wardle.FischerList{} },
PredicateFunc: MatchFischer, PredicateFunc: MatchFischer,
QualifiedResource: wardle.Resource("fischers"), DefaultQualifiedResource: wardle.Resource("fischers"),
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,

View File

@ -29,11 +29,11 @@ func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*reg
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{} },
PredicateFunc: MatchFlunder, PredicateFunc: MatchFlunder,
QualifiedResource: wardle.Resource("flunders"), DefaultQualifiedResource: wardle.Resource("flunders"),
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,