Skip to content

Commit

Permalink
fix(platform): api-resources failed group error (#1701)
Browse files Browse the repository at this point in the history
Co-authored-by: xdonggao <[email protected]>
  • Loading branch information
GaoXiaodong and xdonggao authored Dec 7, 2021
1 parent b614049 commit 310e18e
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 354 deletions.
10 changes: 9 additions & 1 deletion api/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/platform/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,8 @@ type ClusterGroupAPIResourceItemsList struct {
metav1.ListMeta
// List of ClusterAPIResource
Items []ClusterGroupAPIResourceItems
// Failed Group Error
FailedGroupError string
}

// +genclient
Expand Down
739 changes: 390 additions & 349 deletions api/platform/v1/generated.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/platform/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/platform/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ type ClusterGroupAPIResourceItemsList struct {
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,3,opt,name=metadata"`
// List of ClusterGroupAPIResourceItems
Items []ClusterGroupAPIResourceItems `protobuf:"bytes,2,rep,name=items"`
// Failed Group Error
FailedGroupError string `json:"failedGroupError" protobuf:"bytes,4,rep,name=failedGroupError"`
}

// +genclient
Expand Down
5 changes: 3 additions & 2 deletions api/platform/v1/types_swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/platform/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions pkg/platform/registry/cluster/storage/api_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package storage

import (
"context"

"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -68,8 +69,9 @@ func (r *APIResourcesREST) Get(ctx context.Context, clusterName string, options
return nil, err
}
lists, err := discoveryclient.ServerPreferredResources()
failedGroup := ""
if err != nil {
return nil, err
failedGroup = err.Error()
}
items := make([]platform.ClusterGroupAPIResourceItems, 0)
for _, list := range lists {
Expand All @@ -96,6 +98,7 @@ func (r *APIResourcesREST) Get(ctx context.Context, clusterName string, options
})
}
return &platform.ClusterGroupAPIResourceItemsList{
Items: items,
Items: items,
FailedGroupError: failedGroup,
}, nil
}

0 comments on commit 310e18e

Please sign in to comment.