Skip to content

Commit

Permalink
adopt fixes from shell-operator client discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Shevchenko committed May 19, 2021
1 parent 343f721 commit 9b81866
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery"
"k8s.io/client-go/discovery/cached/disk"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/dynamic"
fakedynamic "k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -334,7 +335,15 @@ func (c *client) APIResourceList(apiVersion string) (lists []*metav1.APIResource
if apiVersion == "" {
// Get all preferred resources.
// Can return errors if api controllers are not available.
return c.discovery().ServerPreferredResources()
switch c.discovery().(type) {
case *fakediscovery.FakeDiscovery:
_, res, err := c.discovery().ServerGroupsAndResources()
return res, err

default:
return c.discovery().ServerPreferredResources()
}

} else {
// Get only resources for desired group and version
gv, err := schema.ParseGroupVersion(apiVersion)
Expand Down

0 comments on commit 9b81866

Please sign in to comment.