Skip to content

Commit

Permalink
fix(platform): watch cluster/clustercredential/application with optio…
Browse files Browse the repository at this point in the history
…ns (#2307)

Co-authored-by: xdonggao <xdonggao@tencent.com>
  • Loading branch information
GaoXiaodong and xdonggao committed Aug 22, 2023
1 parent 4cd32bb commit 08116ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/application/registry/application/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"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 @@ -119,6 +120,12 @@ func (r *GenericREST) ShortNames() []string {
return []string{"app"}
}

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

// List selects resources in the storage which match to the selector. 'options' can be nil.
func (r *GenericREST) List(ctx context.Context, options *metainternal.ListOptions) (runtime.Object, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
Expand Down
7 changes: 7 additions & 0 deletions pkg/platform/registry/cluster/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 @@ -163,6 +164,12 @@ func (r *REST) ShortNames() []string {
return []string{"cls"}
}

// 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)
}

// List selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) List(ctx context.Context, options *metainternal.ListOptions) (runtime.Object, error) {
wrappedOptions := apiserverutil.PredicateListOptions(ctx, options)
Expand Down
8 changes: 8 additions & 0 deletions pkg/platform/registry/clustercredential/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"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"
platforminternalclient "tkestack.io/tke/api/client/clientset/internalversion/typed/platform/internalversion"
"tkestack.io/tke/api/platform"
"tkestack.io/tke/pkg/apiserver/authentication"
apiserverutil "tkestack.io/tke/pkg/apiserver/util"
"tkestack.io/tke/pkg/platform/registry/clustercredential"
"tkestack.io/tke/pkg/platform/util"
"tkestack.io/tke/pkg/util/log"
Expand Down Expand Up @@ -96,6 +98,12 @@ func (r *REST) ShortNames() []string {
return []string{"cc"}
}

// 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)
}

// List selects resources in the storage which match to the selector. 'options' can be nil.
func (r *REST) List(ctx context.Context, options *metainternal.ListOptions) (runtime.Object, error) {
_, tenantID := authentication.UsernameAndTenantID(ctx)
Expand Down

0 comments on commit 08116ee

Please sign in to comment.