Skip to content

Commit

Permalink
fix(platform): resource watch and deletecollection validate tencentid (
Browse files Browse the repository at this point in the history
…#2319)

Co-authored-by: xdonggao <xdonggao@tencent.com>
  • Loading branch information
GaoXiaodong and xdonggao authored Jun 1, 2024
1 parent a379406 commit e0e2b8b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pkg/platform/registry/cluster/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ func (r *REST) List(ctx context.Context, options *metainternal.ListOptions) (run
// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// Get finds a resource in the storage by name and returns it.
Expand Down
3 changes: 2 additions & 1 deletion pkg/platform/registry/clustercredential/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func (r *REST) List(ctx context.Context, options *metainternal.ListOptions) (run
// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// Get finds a resource in the storage by name and returns it.
Expand Down
10 changes: 9 additions & 1 deletion pkg/platform/registry/cronhpa/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
genericregistry "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
Expand Down Expand Up @@ -131,10 +132,17 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
return r.Store.Delete(ctx, name, deleteValidation, options)
}

// Watch selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) Watch(ctx context.Context, options *metainternal.ListOptions) (watch.Interface, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
return r.Store.Watch(ctx, wrappedOptions)
}

// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// StatusREST implements the REST endpoint for changing the status of a CronHPA.
Expand Down
17 changes: 12 additions & 5 deletions pkg/platform/registry/csioperator/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ package storage
import (
"context"

apiserverutil "tkestack.io/tke/pkg/apiserver/util"
"tkestack.io/tke/pkg/platform/registry/csioperator"
"tkestack.io/tke/pkg/platform/util"

metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
genericregistry "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
"tkestack.io/tke/api/platform"
apiserverutil "tkestack.io/tke/pkg/apiserver/util"
"tkestack.io/tke/pkg/platform/registry/csioperator"
"tkestack.io/tke/pkg/platform/util"
"tkestack.io/tke/pkg/util/log"
)

Expand Down Expand Up @@ -132,10 +132,17 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
return r.Store.Delete(ctx, name, deleteValidation, options)
}

// Watch selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) Watch(ctx context.Context, options *metainternal.ListOptions) (watch.Interface, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
return r.Store.Watch(ctx, wrappedOptions)
}

// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// StatusREST implements the REST endpoint for changing the status of a LogCollector.
Expand Down
10 changes: 9 additions & 1 deletion pkg/platform/registry/machine/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
genericregistry "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
Expand Down Expand Up @@ -247,10 +248,17 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
return r.Store.Delete(ctx, name, deleteValidation, options)
}

// Watch selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) Watch(ctx context.Context, options *metainternal.ListOptions) (watch.Interface, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
return r.Store.Watch(ctx, wrappedOptions)
}

// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// StatusREST implements the REST endpoint for changing the status of a
Expand Down
10 changes: 9 additions & 1 deletion pkg/platform/registry/persistentevent/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
genericregistry "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
Expand Down Expand Up @@ -130,10 +131,17 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
return r.Store.Delete(ctx, name, deleteValidation, options)
}

// Watch selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) Watch(ctx context.Context, options *metainternal.ListOptions) (watch.Interface, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
return r.Store.Watch(ctx, wrappedOptions)
}

// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// StatusREST implements the REST endpoint for changing the status of a replication controller
Expand Down
10 changes: 9 additions & 1 deletion pkg/platform/registry/tappcontroller/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
genericregistry "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
Expand Down Expand Up @@ -131,10 +132,17 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
return r.Store.Delete(ctx, name, deleteValidation, options)
}

// Watch selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) Watch(ctx context.Context, options *metainternal.ListOptions) (watch.Interface, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
return r.Store.Watch(ctx, wrappedOptions)
}

// DeleteCollection selects all resources in the storage matching given 'listOptions'
// and deletes them.
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternal.ListOptions) (runtime.Object, error) {
return r.Store.DeleteCollection(ctx, deleteValidation, options, listOptions)
wrappedOptions := apiserverutil.PredicateListOptions(ctx, listOptions)
return r.Store.DeleteCollection(ctx, deleteValidation, options, wrappedOptions)
}

// StatusREST implements the REST endpoint for changing the status of a tapp controller.
Expand Down

0 comments on commit e0e2b8b

Please sign in to comment.