Allow other client's implementation to reuse NewListWatchFromClient by passing in the Getter interface, responsible for accessing RESTClient's Get method.

This commit is contained in:
Maciej Szulik 2015-08-17 15:25:03 +02:00
parent e9dd3c5543
commit 686f764fc7

View File

@ -37,8 +37,13 @@ type ListWatch struct {
WatchFunc WatchFunc
}
// Getter interface knows how to access Get method from RESTClient.
type Getter interface {
Get() *client.Request
}
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
func NewListWatchFromClient(c *client.Client, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
listFunc := func() (runtime.Object, error) {
return c.Get().
Namespace(namespace).