mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-26 04:36:00 +00:00
Limit all category to apps group for ds/deployment/replicaset
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
// rest implements a RESTStorage for DaemonSets
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
categories []string
|
||||
}
|
||||
|
||||
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
||||
@@ -56,7 +57,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
||||
statusStore := *store
|
||||
statusStore.UpdateStrategy = daemonset.StatusStrategy
|
||||
|
||||
return &REST{store}, &StatusREST{store: &statusStore}
|
||||
return &REST{store, []string{"all"}}, &StatusREST{store: &statusStore}
|
||||
}
|
||||
|
||||
// Implement ShortNamesProvider
|
||||
@@ -71,7 +72,12 @@ var _ rest.CategoriesProvider = &REST{}
|
||||
|
||||
// Categories implements the CategoriesProvider interface. Returns a list of categories a resource is part of.
|
||||
func (r *REST) Categories() []string {
|
||||
return []string{"all"}
|
||||
return r.categories
|
||||
}
|
||||
|
||||
func (r *REST) WithCategories(categories []string) *REST {
|
||||
r.categories = categories
|
||||
return r
|
||||
}
|
||||
|
||||
// StatusREST implements the REST endpoint for changing the status of a daemonset
|
||||
|
@@ -63,6 +63,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter) DeploymentStorage {
|
||||
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
categories []string
|
||||
}
|
||||
|
||||
// NewREST returns a RESTStorage object that will work against deployments.
|
||||
@@ -83,7 +84,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *Rollbac
|
||||
|
||||
statusStore := *store
|
||||
statusStore.UpdateStrategy = deployment.StatusStrategy
|
||||
return &REST{store}, &StatusREST{store: &statusStore}, &RollbackREST{store: store}
|
||||
return &REST{store, []string{"all"}}, &StatusREST{store: &statusStore}, &RollbackREST{store: store}
|
||||
}
|
||||
|
||||
// Implement ShortNamesProvider
|
||||
@@ -99,7 +100,12 @@ var _ rest.CategoriesProvider = &REST{}
|
||||
|
||||
// Categories implements the CategoriesProvider interface. Returns a list of categories a resource is part of.
|
||||
func (r *REST) Categories() []string {
|
||||
return []string{"all"}
|
||||
return r.categories
|
||||
}
|
||||
|
||||
func (r *REST) WithCategories(categories []string) *REST {
|
||||
r.categories = categories
|
||||
return r
|
||||
}
|
||||
|
||||
// StatusREST implements the REST endpoint for changing the status of a deployment
|
||||
|
@@ -62,6 +62,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter) ReplicaSetStorage {
|
||||
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
categories []string
|
||||
}
|
||||
|
||||
// NewREST returns a RESTStorage object that will work against ReplicaSet.
|
||||
@@ -86,7 +87,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
||||
statusStore := *store
|
||||
statusStore.UpdateStrategy = replicaset.StatusStrategy
|
||||
|
||||
return &REST{store}, &StatusREST{store: &statusStore}
|
||||
return &REST{store, []string{"all"}}, &StatusREST{store: &statusStore}
|
||||
}
|
||||
|
||||
// Implement ShortNamesProvider
|
||||
@@ -102,7 +103,12 @@ var _ rest.CategoriesProvider = &REST{}
|
||||
|
||||
// Categories implements the CategoriesProvider interface. Returns a list of categories a resource is part of.
|
||||
func (r *REST) Categories() []string {
|
||||
return []string{"all"}
|
||||
return r.categories
|
||||
}
|
||||
|
||||
func (r *REST) WithCategories(categories []string) *REST {
|
||||
r.categories = categories
|
||||
return r
|
||||
}
|
||||
|
||||
// StatusREST implements the REST endpoint for changing the status of a ReplicaSet
|
||||
|
@@ -62,12 +62,12 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorag
|
||||
|
||||
if apiResourceConfigSource.ResourceEnabled(version.WithResource("daemonsets")) {
|
||||
daemonSetStorage, daemonSetStatusStorage := daemonstore.NewREST(restOptionsGetter)
|
||||
storage["daemonsets"] = daemonSetStorage
|
||||
storage["daemonsets"] = daemonSetStorage.WithCategories(nil)
|
||||
storage["daemonsets/status"] = daemonSetStatusStorage
|
||||
}
|
||||
if apiResourceConfigSource.ResourceEnabled(version.WithResource("deployments")) {
|
||||
deploymentStorage := deploymentstore.NewStorage(restOptionsGetter)
|
||||
storage["deployments"] = deploymentStorage.Deployment
|
||||
storage["deployments"] = deploymentStorage.Deployment.WithCategories(nil)
|
||||
storage["deployments/status"] = deploymentStorage.Status
|
||||
storage["deployments/rollback"] = deploymentStorage.Rollback
|
||||
storage["deployments/scale"] = deploymentStorage.Scale
|
||||
@@ -83,7 +83,7 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorag
|
||||
}
|
||||
if apiResourceConfigSource.ResourceEnabled(version.WithResource("replicasets")) {
|
||||
replicaSetStorage := replicasetstore.NewStorage(restOptionsGetter)
|
||||
storage["replicasets"] = replicaSetStorage.ReplicaSet
|
||||
storage["replicasets"] = replicaSetStorage.ReplicaSet.WithCategories(nil)
|
||||
storage["replicasets/status"] = replicaSetStorage.Status
|
||||
storage["replicasets/scale"] = replicaSetStorage.Scale
|
||||
}
|
||||
|
Reference in New Issue
Block a user