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
500b130f
Unverified
Commit
500b130f
authored
Jul 17, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable paging for all list watchers
parent
fb68d1d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
listwatch_test.go
pkg/client/tests/listwatch_test.go
+1
-0
BUILD
staging/src/k8s.io/client-go/tools/cache/BUILD
+2
-0
listwatch.go
staging/src/k8s.io/client-go/tools/cache/listwatch.go
+9
-2
No files found.
pkg/client/tests/listwatch_test.go
View file @
500b130f
...
@@ -104,6 +104,7 @@ func TestListWatchesCanList(t *testing.T) {
...
@@ -104,6 +104,7 @@ func TestListWatchesCanList(t *testing.T) {
defer
server
.
Close
()
defer
server
.
Close
()
client
:=
clientset
.
NewForConfigOrDie
(
&
restclient
.
Config
{
Host
:
server
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
api
.
Registry
.
GroupOrDie
(
v1
.
GroupName
)
.
GroupVersion
}})
client
:=
clientset
.
NewForConfigOrDie
(
&
restclient
.
Config
{
Host
:
server
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
api
.
Registry
.
GroupOrDie
(
v1
.
GroupName
)
.
GroupVersion
}})
lw
:=
NewListWatchFromClient
(
client
.
Core
()
.
RESTClient
(),
item
.
resource
,
item
.
namespace
,
item
.
fieldSelector
)
lw
:=
NewListWatchFromClient
(
client
.
Core
()
.
RESTClient
(),
item
.
resource
,
item
.
namespace
,
item
.
fieldSelector
)
lw
.
DisablePaging
=
true
// This test merely tests that the correct request is made.
// This test merely tests that the correct request is made.
lw
.
List
(
metav1
.
ListOptions
{})
lw
.
List
(
metav1
.
ListOptions
{})
handler
.
ValidateRequest
(
t
,
item
.
location
,
"GET"
,
nil
)
handler
.
ValidateRequest
(
t
,
item
.
location
,
"GET"
,
nil
)
...
...
staging/src/k8s.io/client-go/tools/cache/BUILD
View file @
500b130f
...
@@ -63,6 +63,7 @@ go_library(
...
@@ -63,6 +63,7 @@ go_library(
],
],
deps = [
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
@@ -79,6 +80,7 @@ go_library(
...
@@ -79,6 +80,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/tools/pager:go_default_library",
],
],
)
)
...
...
staging/src/k8s.io/client-go/tools/cache/listwatch.go
View file @
500b130f
...
@@ -19,12 +19,15 @@ package cache
...
@@ -19,12 +19,15 @@ package cache
import
(
import
(
"time"
"time"
"golang.org/x/net/context"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apimachinery/pkg/watch"
restclient
"k8s.io/client-go/rest"
restclient
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/pager"
)
)
// ListerWatcher is any object that knows how to perform an initial list and start a watch on a resource.
// ListerWatcher is any object that knows how to perform an initial list and start a watch on a resource.
...
@@ -46,8 +49,9 @@ type WatchFunc func(options metav1.ListOptions) (watch.Interface, error)
...
@@ -46,8 +49,9 @@ type WatchFunc func(options metav1.ListOptions) (watch.Interface, error)
// It is a convenience function for users of NewReflector, etc.
// It is a convenience function for users of NewReflector, etc.
// ListFunc and WatchFunc must not be nil
// ListFunc and WatchFunc must not be nil
type
ListWatch
struct
{
type
ListWatch
struct
{
ListFunc
ListFunc
ListFunc
ListFunc
WatchFunc
WatchFunc
WatchFunc
WatchFunc
DisablePaging
bool
}
}
// Getter interface knows how to access Get method from RESTClient.
// Getter interface knows how to access Get method from RESTClient.
...
@@ -87,6 +91,9 @@ func timeoutFromListOptions(options metav1.ListOptions) time.Duration {
...
@@ -87,6 +91,9 @@ func timeoutFromListOptions(options metav1.ListOptions) time.Duration {
// List a set of apiserver resources
// List a set of apiserver resources
func
(
lw
*
ListWatch
)
List
(
options
metav1
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
lw
*
ListWatch
)
List
(
options
metav1
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
if
!
lw
.
DisablePaging
{
return
pager
.
New
(
pager
.
SimplePageFunc
(
lw
.
ListFunc
))
.
List
(
context
.
TODO
(),
options
)
}
return
lw
.
ListFunc
(
options
)
return
lw
.
ListFunc
(
options
)
}
}
...
...
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