From 29c42b997d84f4d6a09430534d7199d1ee334d1f Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Fri, 28 Mar 2025 09:10:15 +0800 Subject: [PATCH] upgrade go-sdk (#916) Signed-off-by: Wei Liu --- go.mod | 2 +- go.sum | 4 ++-- vendor/modules.txt | 2 +- .../sdk-go/pkg/cloudevents/clients/store/base.go | 4 ++-- .../sdk-go/pkg/cloudevents/clients/store/interface.go | 11 ++++++++++- .../sdk-go/pkg/cloudevents/clients/store/lister.go | 4 ++-- .../clients/work/agent/client/manifestwork.go | 4 ++-- .../clients/work/source/client/manifestwork.go | 4 ++-- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 7146ab7fe..d5b9cb101 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 open-cluster-management.io/addon-framework v0.12.0 open-cluster-management.io/api v0.16.1 - open-cluster-management.io/sdk-go v0.16.1-0.20250327030116-e8c524c1a85b + open-cluster-management.io/sdk-go v0.16.1-0.20250327091909-6bd6228a47ad sigs.k8s.io/cluster-inventory-api v0.0.0-20240730014211-ef0154379848 sigs.k8s.io/controller-runtime v0.19.3 sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 diff --git a/go.sum b/go.sum index 2f2ac5699..050b9247d 100644 --- a/go.sum +++ b/go.sum @@ -491,8 +491,8 @@ open-cluster-management.io/addon-framework v0.12.0 h1:5j7mpyk2ij0SLUZkwWk0KkNTWt open-cluster-management.io/addon-framework v0.12.0/go.mod h1:eReMWXrEHqtilwz5wzEpUrWw9Vfz0HJCH9pi3gOTZns= open-cluster-management.io/api v0.16.1 h1:mS+4UGxHLPQd7CRM0gdFQdVaz139Lo2bkLfqSE0CDNU= open-cluster-management.io/api v0.16.1/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM= -open-cluster-management.io/sdk-go v0.16.1-0.20250327030116-e8c524c1a85b h1:MjK6LuPi6kPMG40kMfzV2c7lffmwscUmspXmNGyezV4= -open-cluster-management.io/sdk-go v0.16.1-0.20250327030116-e8c524c1a85b/go.mod h1:TyOjZC5YxyM5BRNgwTmLuTbHXX6xXqzYBXllrfoVp9w= +open-cluster-management.io/sdk-go v0.16.1-0.20250327091909-6bd6228a47ad h1:37f9TEwX/U8esBjSJvPleDM3rcFpk9NY5e2ItjO6PcQ= +open-cluster-management.io/sdk-go v0.16.1-0.20250327091909-6bd6228a47ad/go.mod h1:TyOjZC5YxyM5BRNgwTmLuTbHXX6xXqzYBXllrfoVp9w= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsAtVhSeUFseziht227YAWYHLGNM8QPwY= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/cluster-inventory-api v0.0.0-20240730014211-ef0154379848 h1:WYPi2PdQyZwZkHG648v2jQl6deyCgyjJ0fkLYgUJ618= diff --git a/vendor/modules.txt b/vendor/modules.txt index 2de51d5c1..005356c58 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1777,7 +1777,7 @@ open-cluster-management.io/api/operator/v1 open-cluster-management.io/api/utils/work/v1/workapplier open-cluster-management.io/api/work/v1 open-cluster-management.io/api/work/v1alpha1 -# open-cluster-management.io/sdk-go v0.16.1-0.20250327030116-e8c524c1a85b +# open-cluster-management.io/sdk-go v0.16.1-0.20250327091909-6bd6228a47ad ## explicit; go 1.22.0 open-cluster-management.io/sdk-go/pkg/apis/cluster/v1alpha1 open-cluster-management.io/sdk-go/pkg/apis/cluster/v1beta1 diff --git a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/base.go b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/base.go index 577130c3b..fff4ae426 100644 --- a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/base.go +++ b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/base.go @@ -20,7 +20,7 @@ type BaseClientWatchStore[T generic.ResourceObject] struct { } // List the resources from the store with the list options -func (s *BaseClientWatchStore[T]) List(namespace string, opts metav1.ListOptions) ([]T, error) { +func (s *BaseClientWatchStore[T]) List(namespace string, opts metav1.ListOptions) (*ResourceList[T], error) { s.RLock() defer s.RUnlock() @@ -29,7 +29,7 @@ func (s *BaseClientWatchStore[T]) List(namespace string, opts metav1.ListOptions return nil, err } - return resources, nil + return &ResourceList[T]{Items: resources}, nil } // Get a resource from the store diff --git a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/interface.go b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/interface.go index eb705a396..6495e9cda 100644 --- a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/interface.go +++ b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/interface.go @@ -16,6 +16,15 @@ import ( const syncedPollPeriod = 100 * time.Millisecond +// ResourceList is a collection of resources. +type ResourceList[T generic.ResourceObject] struct { + // ListMeta describes list metadata + metav1.ListMeta + + // Items is a list of resources. + Items []T +} + // StoreInitiated is a function that can be used to determine if a store has initiated. type StoreInitiated func() bool @@ -40,7 +49,7 @@ type ClientWatcherStore[T generic.ResourceObject] interface { Delete(resource runtime.Object) error // List returns the resources from store for a given namespace with list options - List(namespace string, opts metav1.ListOptions) ([]T, error) + List(namespace string, opts metav1.ListOptions) (*ResourceList[T], error) // ListAll list all of the resources from store ListAll() ([]T, error) diff --git a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/lister.go b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/lister.go index b0b2b2f49..7362befd5 100644 --- a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/lister.go +++ b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/store/lister.go @@ -34,7 +34,7 @@ func (l *AgentWatcherStoreLister[T]) List(options types.ListOptions) ([]T, error return nil, err } - return list, nil + return list.Items, nil } // SourceWatcherStoreLister list the resources from a ClientWatcherStore on a source. @@ -55,5 +55,5 @@ func (l *SourceWatcherStoreLister[T]) List(options types.ListOptions) ([]T, erro return nil, err } - return list, nil + return list.Items, nil } diff --git a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/agent/client/manifestwork.go b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/agent/client/manifestwork.go index 8bee84087..20375a2b9 100644 --- a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/agent/client/manifestwork.go +++ b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/agent/client/manifestwork.go @@ -103,11 +103,11 @@ func (c *ManifestWorkAgentClient) List(ctx context.Context, opts metav1.ListOpti generic.IncreaseWorkProcessedCounter("list", metav1.StatusSuccess) items := []workv1.ManifestWork{} - for _, work := range works { + for _, work := range works.Items { items = append(items, *work) } - return &workv1.ManifestWorkList{Items: items}, nil + return &workv1.ManifestWorkList{ListMeta: works.ListMeta, Items: items}, nil } func (c *ManifestWorkAgentClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { diff --git a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/source/client/manifestwork.go b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/source/client/manifestwork.go index 52c022cc8..b99a5fae9 100644 --- a/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/source/client/manifestwork.go +++ b/vendor/open-cluster-management.io/sdk-go/pkg/cloudevents/clients/work/source/client/manifestwork.go @@ -212,11 +212,11 @@ func (c *ManifestWorkSourceClient) List(ctx context.Context, opts metav1.ListOpt generic.IncreaseWorkProcessedCounter("list", metav1.StatusSuccess) items := []workv1.ManifestWork{} - for _, work := range works { + for _, work := range works.Items { items = append(items, *work) } - return &workv1.ManifestWorkList{Items: items}, nil + return &workv1.ManifestWorkList{ListMeta: works.ListMeta, Items: items}, nil } func (c *ManifestWorkSourceClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {