mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fix goling issues for pkg/registry/apps
This commit is contained in:
parent
007f7ae7dc
commit
3ab5ea09ed
@ -128,10 +128,6 @@ pkg/proxy/userspace
|
||||
pkg/proxy/winkernel
|
||||
pkg/proxy/winuserspace
|
||||
pkg/registry/admissionregistration/rest
|
||||
pkg/registry/apps/deployment/storage
|
||||
pkg/registry/apps/replicaset/storage
|
||||
pkg/registry/apps/rest
|
||||
pkg/registry/apps/statefulset/storage
|
||||
pkg/registry/auditregistration/rest
|
||||
pkg/registry/authentication/rest
|
||||
pkg/registry/authentication/tokenreview
|
||||
|
@ -432,7 +432,7 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
|
||||
flowcontrolrest.RESTStorageProvider{},
|
||||
// keep apps after extensions so legacy clients resolve the extensions versions of shared resource names.
|
||||
// See https://github.com/kubernetes/kubernetes/issues/42392
|
||||
appsrest.RESTStorageProvider{},
|
||||
appsrest.StorageProvider{},
|
||||
admissionregistrationrest.RESTStorageProvider{},
|
||||
eventsrest.RESTStorageProvider{TTL: c.ExtraConfig.EventTTL},
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ type DeploymentStorage struct {
|
||||
Rollback *RollbackREST
|
||||
}
|
||||
|
||||
// NewStorage returns new instance of DeploymentStorage.
|
||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (DeploymentStorage, error) {
|
||||
deploymentRest, deploymentStatusRest, deploymentRollbackRest, err := NewREST(optsGetter)
|
||||
if err != nil {
|
||||
@ -67,6 +68,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter) (DeploymentStorage, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
// REST implements a RESTStorage for Deployments.
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
categories []string
|
||||
@ -111,6 +113,7 @@ func (r *REST) Categories() []string {
|
||||
return r.categories
|
||||
}
|
||||
|
||||
// WithCategories sets categories for REST.
|
||||
func (r *REST) WithCategories(categories []string) *REST {
|
||||
r.categories = categories
|
||||
return r
|
||||
@ -121,6 +124,7 @@ type StatusREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
|
||||
// New returns empty Deployment object.
|
||||
func (r *StatusREST) New() runtime.Object {
|
||||
return &apps.Deployment{}
|
||||
}
|
||||
@ -163,6 +167,7 @@ func (r *RollbackREST) New() runtime.Object {
|
||||
|
||||
var _ = rest.NamedCreater(&RollbackREST{})
|
||||
|
||||
// Create runs rollback for deployment
|
||||
func (r *RollbackREST) Create(ctx context.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||
rollback, ok := obj.(*apps.DeploymentRollback)
|
||||
if !ok {
|
||||
@ -230,6 +235,7 @@ func (r *RollbackREST) setDeploymentRollback(ctx context.Context, deploymentID s
|
||||
return finalDeployment, err
|
||||
}
|
||||
|
||||
// ScaleREST implements a Scale for Deployment.
|
||||
type ScaleREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
@ -238,6 +244,7 @@ type ScaleREST struct {
|
||||
var _ = rest.Patcher(&ScaleREST{})
|
||||
var _ = rest.GroupVersionKindProvider(&ScaleREST{})
|
||||
|
||||
// GroupVersionKind returns GroupVersionKind for Deployment Scale object
|
||||
func (r *ScaleREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind {
|
||||
switch containingGV {
|
||||
case extensionsv1beta1.SchemeGroupVersion:
|
||||
@ -256,6 +263,7 @@ func (r *ScaleREST) New() runtime.Object {
|
||||
return &autoscaling.Scale{}
|
||||
}
|
||||
|
||||
// Get retrieves object from Scale storage.
|
||||
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||
obj, err := r.store.Get(ctx, name, options)
|
||||
if err != nil {
|
||||
@ -269,6 +277,7 @@ func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOpt
|
||||
return scale, nil
|
||||
}
|
||||
|
||||
// Update alters scale subset of Deployment object.
|
||||
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
@ -49,6 +49,7 @@ type ReplicaSetStorage struct {
|
||||
Scale *ScaleREST
|
||||
}
|
||||
|
||||
// NewStorage returns new instance of ReplicaSetStorage.
|
||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (ReplicaSetStorage, error) {
|
||||
replicaSetRest, replicaSetStatusRest, err := NewREST(optsGetter)
|
||||
if err != nil {
|
||||
@ -62,6 +63,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter) (ReplicaSetStorage, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
// REST implements a RESTStorage for ReplicaSet.
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
categories []string
|
||||
@ -108,6 +110,7 @@ func (r *REST) Categories() []string {
|
||||
return r.categories
|
||||
}
|
||||
|
||||
// WithCategories sets categories for REST.
|
||||
func (r *REST) WithCategories(categories []string) *REST {
|
||||
r.categories = categories
|
||||
return r
|
||||
@ -118,6 +121,7 @@ type StatusREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
|
||||
// New returns empty ReplicaSet object.
|
||||
func (r *StatusREST) New() runtime.Object {
|
||||
return &apps.ReplicaSet{}
|
||||
}
|
||||
@ -134,6 +138,7 @@ func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.Updat
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options)
|
||||
}
|
||||
|
||||
// ScaleREST implements a Scale for Deployment.
|
||||
type ScaleREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
@ -142,6 +147,7 @@ type ScaleREST struct {
|
||||
var _ = rest.Patcher(&ScaleREST{})
|
||||
var _ = rest.GroupVersionKindProvider(&ScaleREST{})
|
||||
|
||||
// GroupVersionKind returns GroupVersionKind for ReplicaSet Scale object
|
||||
func (r *ScaleREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind {
|
||||
switch containingGV {
|
||||
case extensionsv1beta1.SchemeGroupVersion:
|
||||
@ -160,6 +166,7 @@ func (r *ScaleREST) New() runtime.Object {
|
||||
return &autoscaling.Scale{}
|
||||
}
|
||||
|
||||
// Get retrieves object from Scale storage.
|
||||
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||
obj, err := r.store.Get(ctx, name, options)
|
||||
if err != nil {
|
||||
@ -173,6 +180,7 @@ func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOpt
|
||||
return scale, err
|
||||
}
|
||||
|
||||
// Update alters scale subset of ReplicaSet object.
|
||||
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
@ -31,25 +31,27 @@ import (
|
||||
statefulsetstore "k8s.io/kubernetes/pkg/registry/apps/statefulset/storage"
|
||||
)
|
||||
|
||||
type RESTStorageProvider struct{}
|
||||
// StorageProvider is a struct for apps REST storage.
|
||||
type StorageProvider struct{}
|
||||
|
||||
func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool, error) {
|
||||
// NewRESTStorage returns APIGroupInfo object.
|
||||
func (p StorageProvider) NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool, error) {
|
||||
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apps.GroupName, legacyscheme.Scheme, legacyscheme.ParameterCodec, legacyscheme.Codecs)
|
||||
// If you add a version here, be sure to add an entry in `k8s.io/kubernetes/cmd/kube-apiserver/app/aggregator.go with specific priorities.
|
||||
// TODO refactor the plumbing to provide the information in the APIGroupInfo
|
||||
|
||||
if apiResourceConfigSource.VersionEnabled(appsapiv1.SchemeGroupVersion) {
|
||||
if storageMap, err := p.v1Storage(apiResourceConfigSource, restOptionsGetter); err != nil {
|
||||
storageMap, err := p.v1Storage(apiResourceConfigSource, restOptionsGetter)
|
||||
if err != nil {
|
||||
return genericapiserver.APIGroupInfo{}, false, err
|
||||
} else {
|
||||
apiGroupInfo.VersionedResourcesStorageMap[appsapiv1.SchemeGroupVersion.Version] = storageMap
|
||||
}
|
||||
apiGroupInfo.VersionedResourcesStorageMap[appsapiv1.SchemeGroupVersion.Version] = storageMap
|
||||
}
|
||||
|
||||
return apiGroupInfo, true, nil
|
||||
}
|
||||
|
||||
func (p RESTStorageProvider) v1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) {
|
||||
func (p StorageProvider) v1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) {
|
||||
storage := map[string]rest.Storage{}
|
||||
|
||||
// deployments
|
||||
@ -97,6 +99,7 @@ func (p RESTStorageProvider) v1Storage(apiResourceConfigSource serverstorage.API
|
||||
return storage, nil
|
||||
}
|
||||
|
||||
func (p RESTStorageProvider) GroupName() string {
|
||||
// GroupName returns name of the group
|
||||
func (p StorageProvider) GroupName() string {
|
||||
return apps.GroupName
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ type StatefulSetStorage struct {
|
||||
Scale *ScaleREST
|
||||
}
|
||||
|
||||
// NewStorage returns new instance of StatefulSetStorage.
|
||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (StatefulSetStorage, error) {
|
||||
statefulSetRest, statefulSetStatusRest, err := NewREST(optsGetter)
|
||||
if err != nil {
|
||||
@ -59,7 +60,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter) (StatefulSetStorage, error
|
||||
}, nil
|
||||
}
|
||||
|
||||
// rest implements a RESTStorage for statefulsets against etcd
|
||||
// REST implements a RESTStorage for statefulsets against etcd
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
}
|
||||
@ -100,6 +101,7 @@ type StatusREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
|
||||
// New returns empty StatefulSet object.
|
||||
func (r *StatusREST) New() runtime.Object {
|
||||
return &apps.StatefulSet{}
|
||||
}
|
||||
@ -124,6 +126,7 @@ func (r *REST) ShortNames() []string {
|
||||
return []string{"sts"}
|
||||
}
|
||||
|
||||
// ScaleREST implements a Scale for Deployment.
|
||||
type ScaleREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
@ -132,6 +135,7 @@ type ScaleREST struct {
|
||||
var _ = rest.Patcher(&ScaleREST{})
|
||||
var _ = rest.GroupVersionKindProvider(&ScaleREST{})
|
||||
|
||||
// GroupVersionKind returns GroupVersionKind for StatefulSet Scale object
|
||||
func (r *ScaleREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind {
|
||||
switch containingGV {
|
||||
case appsv1beta1.SchemeGroupVersion:
|
||||
@ -148,6 +152,7 @@ func (r *ScaleREST) New() runtime.Object {
|
||||
return &autoscaling.Scale{}
|
||||
}
|
||||
|
||||
// Get retrieves object from Scale storage.
|
||||
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||
obj, err := r.store.Get(ctx, name, options)
|
||||
if err != nil {
|
||||
@ -161,6 +166,7 @@ func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOpt
|
||||
return scale, err
|
||||
}
|
||||
|
||||
// Update alters scale subset of StatefulSet object.
|
||||
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user