Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
74b7cec0
Unverified
Commit
74b7cec0
authored
May 03, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ServerPreferred[Namespaced]Resources logic and caches consistent
parent
bb4745da
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
11 deletions
+15
-11
cached_discovery.go
pkg/kubectl/cmd/util/cached_discovery.go
+2
-2
memcache.go
staging/src/k8s.io/client-go/discovery/cached/memcache.go
+2
-8
discovery_client.go
staging/src/k8s.io/client-go/discovery/discovery_client.go
+11
-1
No files found.
pkg/kubectl/cmd/util/cached_discovery.go
View file @
74b7cec0
...
@@ -220,11 +220,11 @@ func (d *CachedDiscoveryClient) RESTClient() restclient.Interface {
...
@@ -220,11 +220,11 @@ func (d *CachedDiscoveryClient) RESTClient() restclient.Interface {
}
}
func
(
d
*
CachedDiscoveryClient
)
ServerPreferredResources
()
([]
*
metav1
.
APIResourceList
,
error
)
{
func
(
d
*
CachedDiscoveryClient
)
ServerPreferredResources
()
([]
*
metav1
.
APIResourceList
,
error
)
{
return
d
.
delegate
.
ServerPreferredResources
(
)
return
d
iscovery
.
ServerPreferredResources
(
d
)
}
}
func
(
d
*
CachedDiscoveryClient
)
ServerPreferredNamespacedResources
()
([]
*
metav1
.
APIResourceList
,
error
)
{
func
(
d
*
CachedDiscoveryClient
)
ServerPreferredNamespacedResources
()
([]
*
metav1
.
APIResourceList
,
error
)
{
return
d
.
delegate
.
ServerPreferredNamespacedResources
(
)
return
d
iscovery
.
ServerPreferredNamespacedResources
(
d
)
}
}
func
(
d
*
CachedDiscoveryClient
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
func
(
d
*
CachedDiscoveryClient
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
...
...
staging/src/k8s.io/client-go/discovery/cached/memcache.go
View file @
74b7cec0
...
@@ -96,18 +96,12 @@ func (d *memCacheClient) RESTClient() restclient.Interface {
...
@@ -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
d
iscovery
.
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
d
iscovery
.
ServerPreferredNamespacedResources
(
d
)
}
}
func
(
d
*
memCacheClient
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
func
(
d
*
memCacheClient
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
...
...
staging/src/k8s.io/client-go/discovery/discovery_client.go
View file @
74b7cec0
...
@@ -250,6 +250,11 @@ func IsGroupDiscoveryFailedError(err error) bool {
...
@@ -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,
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment