mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-27 15:43:48 +00:00
Make ServerPreferred[Namespaced]Resources logic and caches consistent
Kubernetes-commit: 74b7cec0c6b1355615097be4068500761a9893fd
This commit is contained in:
committed by
Kubernetes Publisher
parent
998a5ff4b9
commit
46ab86af26
@@ -96,18 +96,12 @@ func (d *memCacheClient) RESTClient() restclient.Interface {
|
|||||||
return d.delegate.RESTClient()
|
return d.delegate.RESTClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should this also be cached? The results seem more likely to be
|
|
||||||
// inconsistent with ServerGroups and ServerResources given the requirement to
|
|
||||||
// actively Invalidate.
|
|
||||||
func (d *memCacheClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
|
func (d *memCacheClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
|
||||||
return d.delegate.ServerPreferredResources()
|
return discovery.ServerPreferredResources(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should this also be cached? The results seem more likely to be
|
|
||||||
// inconsistent with ServerGroups and ServerResources given the requirement to
|
|
||||||
// actively Invalidate.
|
|
||||||
func (d *memCacheClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
|
func (d *memCacheClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
|
||||||
return d.delegate.ServerPreferredNamespacedResources()
|
return discovery.ServerPreferredNamespacedResources(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *memCacheClient) ServerVersion() (*version.Info, error) {
|
func (d *memCacheClient) ServerVersion() (*version.Info, error) {
|
||||||
|
@@ -250,6 +250,11 @@ func IsGroupDiscoveryFailedError(err error) bool {
|
|||||||
|
|
||||||
// serverPreferredResources returns the supported resources with the version preferred by the server.
|
// serverPreferredResources returns the supported resources with the version preferred by the server.
|
||||||
func (d *DiscoveryClient) serverPreferredResources() ([]*metav1.APIResourceList, error) {
|
func (d *DiscoveryClient) serverPreferredResources() ([]*metav1.APIResourceList, error) {
|
||||||
|
return ServerPreferredResources(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerPreferredResources uses the provided discovery interface to look up preferred resources
|
||||||
|
func ServerPreferredResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error) {
|
||||||
serverGroupList, err := d.ServerGroups()
|
serverGroupList, err := d.ServerGroups()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -319,7 +324,12 @@ func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList,
|
|||||||
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
|
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
|
||||||
// version preferred by the server.
|
// version preferred by the server.
|
||||||
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
|
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
|
||||||
all, err := d.ServerPreferredResources()
|
return ServerPreferredNamespacedResources(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerPreferredNamespacedResources uses the provided discovery interface to look up preferred namespaced resources
|
||||||
|
func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error) {
|
||||||
|
all, err := ServerPreferredResources(d)
|
||||||
return FilteredBy(ResourcePredicateFunc(func(groupVersion string, r *metav1.APIResource) bool {
|
return FilteredBy(ResourcePredicateFunc(func(groupVersion string, r *metav1.APIResource) bool {
|
||||||
return r.Namespaced
|
return r.Namespaced
|
||||||
}), all), err
|
}), all), err
|
||||||
|
Reference in New Issue
Block a user