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:
parent
681b9464d2
commit
37ba914420
|
@ -98,6 +98,12 @@ func (r *StandardREST) Watch(ctx context.Context, options *metainternalversion.L
|
||||||
return nil, nil
|
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.
|
// GroupVersionKind implement GroupVersionKind interface.
|
||||||
func (r *StatusREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind {
|
func (r *StatusREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind {
|
||||||
return r.cfg.gvk
|
return r.cfg.gvk
|
||||||
|
@ -118,6 +124,12 @@ func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOp
|
||||||
return r.New(), nil
|
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.
|
// New returns an empty cluster proxy subresource.
|
||||||
func (r *ProxyREST) New() runtime.Object {
|
func (r *ProxyREST) New() runtime.Object {
|
||||||
return &clusterv1alpha1.ClusterProxyOptions{}
|
return &clusterv1alpha1.ClusterProxyOptions{}
|
||||||
|
@ -138,6 +150,12 @@ func (r *ProxyREST) Connect(ctx context.Context, id string, options runtime.Obje
|
||||||
return nil, nil
|
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.
|
// ResourceInfo is content of StandardREST.
|
||||||
type ResourceInfo struct {
|
type ResourceInfo struct {
|
||||||
gvk schema.GroupVersionKind
|
gvk schema.GroupVersionKind
|
||||||
|
|
|
@ -79,7 +79,7 @@ func NewCmdApply(f util.Factory, parentCommand string, streams genericclioptions
|
||||||
if err := o.Complete(f, cmd, parentCommand, args); err != nil {
|
if err := o.Complete(f, cmd, parentCommand, args); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := o.Validate(cmd, args); err != nil {
|
if err := o.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return o.Run()
|
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.
|
// 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 {
|
if o.AllClusters && len(o.Clusters) > 0 {
|
||||||
return fmt.Errorf("--all-clusters and --cluster cannot be used together")
|
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 utilerrors.NewAggregate(errs)
|
||||||
}
|
}
|
||||||
return o.kubectlApplyOptions.Validate(cmd, args)
|
return o.kubectlApplyOptions.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the `apply` command.
|
// Run executes the `apply` command.
|
||||||
|
|
|
@ -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)
|
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.
|
||||||
|
}
|
||||||
|
|
|
@ -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 {
|
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||||
return r.store.GetResetFields()
|
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.
|
||||||
|
}
|
||||||
|
|
|
@ -70,3 +70,9 @@ func (r *ProxyingREST) Connect(ctx context.Context, _ string, _ runtime.Object,
|
||||||
klog.V(4).Infof("ProxyingREST connect %v", proxyPath)
|
klog.V(4).Infof("ProxyingREST connect %v", proxyPath)
|
||||||
return r.ctl.Connect(ctx, proxyPath, responder)
|
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.
|
||||||
|
}
|
||||||
|
|
|
@ -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 {
|
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||||
return r.store.GetResetFields()
|
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.
|
||||||
|
}
|
||||||
|
|
|
@ -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)
|
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.
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
cacherstorage "k8s.io/apiserver/pkg/storage/cacher"
|
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"
|
||||||
"k8s.io/apiserver/pkg/storage/storagebackend/factory"
|
"k8s.io/apiserver/pkg/storage/storagebackend/factory"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
@ -120,7 +119,7 @@ var (
|
||||||
restCreateStrategyForNamespaced = &simpleRESTCreateStrategy{namespaced: true}
|
restCreateStrategyForNamespaced = &simpleRESTCreateStrategy{namespaced: true}
|
||||||
restCreateStrategyForCluster = &simpleRESTCreateStrategy{namespaced: false}
|
restCreateStrategyForCluster = &simpleRESTCreateStrategy{namespaced: false}
|
||||||
restDeleteStrategy = &simpleRESTDeleteStrategy{RESTDeleteStrategy: runtime.NewScheme()}
|
restDeleteStrategy = &simpleRESTDeleteStrategy{RESTDeleteStrategy: runtime.NewScheme()}
|
||||||
defaultVersioner = etcd3.APIObjectVersioner{}
|
defaultVersioner = storage.APIObjectVersioner{}
|
||||||
)
|
)
|
||||||
|
|
||||||
type simpleRESTDeleteStrategy struct {
|
type simpleRESTDeleteStrategy struct {
|
||||||
|
|
Loading…
Reference in New Issue