Skip to content

Commit

Permalink
Handle multi-version GKs in resourceSummaries (#310)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Jul 12, 2024
1 parent 01757cf commit 817f0dc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/registry/core/resourcesummary/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
rscoreapi "kmodules.xyz/resource-metadata/apis/core/v1alpha1"
resourcemetrics "kmodules.xyz/resource-metrics"
"kmodules.xyz/resource-metrics/api"
ksets "kmodules.xyz/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -111,12 +112,21 @@ func (r *Storage) List(ctx context.Context, options *internalversion.ListOptions
selector := shared.NewGroupKindSelector(options.LabelSelector)
now := time.Now()

universe := ksets.NewGroupKind()

items := make([]rscoreapi.ResourceSummary, 0)
for _, gvk := range api.RegisteredTypes() {
if !selector.Matches(gvk.GroupKind()) {
continue
}

gk := gvk.GroupKind()
if universe.Has(gk) {
continue
} else {
universe.Insert(gk)
}

mapping, err := r.kc.RESTMapper().RESTMapping(gvk.GroupKind(), gvk.Version)
if meta.IsNoMatchError(err) {
continue
Expand Down

0 comments on commit 817f0dc

Please sign in to comment.