quick fix for StandardStorage interface extension

quick fix for kubectl apply options validation

Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
This commit is contained in:
RainbowMango 2022-11-22 12:30:55 +08:00
parent 681b9464d2
commit 37ba914420
8 changed files with 52 additions and 5 deletions

View File

@ -98,6 +98,12 @@ func (r *StandardREST) Watch(ctx context.Context, options *metainternalversion.L
return nil, nil
}
// Destroy cleans up its resources on shutdown.
func (r *StandardREST) Destroy() {
// Given no underlying store, so we don't
// need to destroy anything.
}
// GroupVersionKind implement GroupVersionKind interface.
func (r *StatusREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind {
return r.cfg.gvk
@ -118,6 +124,12 @@ func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOp
return r.New(), nil
}
// Destroy cleans up its resources on shutdown.
func (r *StatusREST) Destroy() {
// Given no underlying store, so we don't
// need to destroy anything.
}
// New returns an empty cluster proxy subresource.
func (r *ProxyREST) New() runtime.Object {
return &clusterv1alpha1.ClusterProxyOptions{}
@ -138,6 +150,12 @@ func (r *ProxyREST) Connect(ctx context.Context, id string, options runtime.Obje
return nil, nil
}
// Destroy cleans up its resources on shutdown.
func (r *ProxyREST) Destroy() {
// Given no underlying store, so we don't
// need to destroy anything.
}
// ResourceInfo is content of StandardREST.
type ResourceInfo struct {
gvk schema.GroupVersionKind

View File

@ -79,7 +79,7 @@ func NewCmdApply(f util.Factory, parentCommand string, streams genericclioptions
if err := o.Complete(f, cmd, parentCommand, args); err != nil {
return err
}
if err := o.Validate(cmd, args); err != nil {
if err := o.Validate(); err != nil {
return err
}
return o.Run()
@ -115,7 +115,7 @@ func (o *CommandApplyOptions) Complete(f util.Factory, cmd *cobra.Command, paren
}
// Validate verifies if CommandApplyOptions are valid and without conflicts.
func (o *CommandApplyOptions) Validate(cmd *cobra.Command, args []string) error {
func (o *CommandApplyOptions) Validate() error {
if o.AllClusters && len(o.Clusters) > 0 {
return fmt.Errorf("--all-clusters and --cluster cannot be used together")
}
@ -136,7 +136,7 @@ func (o *CommandApplyOptions) Validate(cmd *cobra.Command, args []string) error
}
return utilerrors.NewAggregate(errs)
}
return o.kubectlApplyOptions.Validate(cmd, args)
return o.kubectlApplyOptions.Validate()
}
// Run executes the `apply` command.

View File

@ -58,3 +58,9 @@ func (r *ProxyREST) Connect(ctx context.Context, id string, options runtime.Obje
}
return proxy.ConnectCluster(ctx, cluster, proxyOpts.Path, secretGetter, responder)
}
// Destroy cleans up its resources on shutdown.
func (r *ProxyREST) Destroy() {
// Given no underlying store, so we don't
// need to destroy anything.
}

View File

@ -128,3 +128,9 @@ func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.Updat
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
return r.store.GetResetFields()
}
// Destroy cleans up its resources on shutdown.
func (r *StatusREST) Destroy() {
// Given that underlying 'store' is shared with REST,
// we don't have anything else need to be destroyed.
}

View File

@ -70,3 +70,9 @@ func (r *ProxyingREST) Connect(ctx context.Context, _ string, _ runtime.Object,
klog.V(4).Infof("ProxyingREST connect %v", proxyPath)
return r.ctl.Connect(ctx, proxyPath, responder)
}
// Destroy cleans up its resources on shutdown.
func (r *ProxyingREST) Destroy() {
// Given no underlying store, so we don't
// need to destroy anything.
}

View File

@ -86,3 +86,9 @@ func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.Updat
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
return r.store.GetResetFields()
}
// Destroy cleans up its resources on shutdown.
func (r *StatusREST) Destroy() {
// Given that underlying 'store' is shared with REST,
// we don't have anything else need to be destroyed.
}

View File

@ -92,3 +92,9 @@ func (r *SearchREST) Connect(ctx context.Context, id string, _ runtime.Object, r
return nil, fmt.Errorf("connect with unrecognized search category %s", id)
}
}
// Destroy cleans up its resources on shutdown.
func (r *SearchREST) Destroy() {
// Given no underlying store, so we don't
// need to destroy anything.
}

View File

@ -16,7 +16,6 @@ import (
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage"
cacherstorage "k8s.io/apiserver/pkg/storage/cacher"
"k8s.io/apiserver/pkg/storage/etcd3"
"k8s.io/apiserver/pkg/storage/storagebackend"
"k8s.io/apiserver/pkg/storage/storagebackend/factory"
utilfeature "k8s.io/apiserver/pkg/util/feature"
@ -120,7 +119,7 @@ var (
restCreateStrategyForNamespaced = &simpleRESTCreateStrategy{namespaced: true}
restCreateStrategyForCluster = &simpleRESTCreateStrategy{namespaced: false}
restDeleteStrategy = &simpleRESTDeleteStrategy{RESTDeleteStrategy: runtime.NewScheme()}
defaultVersioner = etcd3.APIObjectVersioner{}
defaultVersioner = storage.APIObjectVersioner{}
)
type simpleRESTDeleteStrategy struct {