Merge pull request #5493 from sdminonne/issue_341_step_2

Another step to introduce  fields.Selector
This commit is contained in:
Nikhil Jindal 2015-03-17 15:16:18 -07:00
commit 89f18f6fe1
42 changed files with 161 additions and 114 deletions

View File

@ -29,6 +29,7 @@ import (
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
kfields "github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
klabels "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" klabels "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
tools "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" tools "github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
kwatch "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" kwatch "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -194,7 +195,7 @@ func main() {
// across ALL namespaces // across ALL namespaces
type servicesWatcher interface { type servicesWatcher interface {
List(label klabels.Selector) (*kapi.ServiceList, error) List(label klabels.Selector) (*kapi.ServiceList, error)
Watch(label, field klabels.Selector, resourceVersion string) (kwatch.Interface, error) Watch(label klabels.Selector, field kfields.Selector, resourceVersion string) (kwatch.Interface, error)
} }
type operation int type operation int
@ -239,7 +240,7 @@ func watchLoop(svcWatcher servicesWatcher, updates chan<- serviceUpdate, resourc
updates <- serviceUpdate{Op: SetServices, Services: services.Items} updates <- serviceUpdate{Op: SetServices, Services: services.Items}
} }
watcher, err := svcWatcher.Watch(klabels.Everything(), klabels.Everything(), *resourceVersion) watcher, err := svcWatcher.Watch(klabels.Everything(), kfields.Everything(), *resourceVersion)
if err != nil { if err != nil {
log.Printf("Failed to watch for service changes: %v", err) log.Printf("Failed to watch for service changes: %v", err)
return return

View File

@ -19,7 +19,7 @@ package cache
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -39,12 +39,12 @@ type ListWatch struct {
} }
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector. // NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
func NewListWatchFromClient(c *client.Client, resource string, namespace string, fieldSelector labels.Selector) *ListWatch { func NewListWatchFromClient(c *client.Client, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
listFunc := func() (runtime.Object, error) { listFunc := func() (runtime.Object, error) {
return c.Get().Namespace(namespace).Resource(resource).SelectorParam(api.FieldSelectorQueryParam(c.APIVersion()), fieldSelector).Do().Get() return c.Get().Namespace(namespace).Resource(resource).FieldsSelectorParam(api.FieldSelectorQueryParam(c.APIVersion()), fieldSelector).Do().Get()
} }
watchFunc := func(resourceVersion string) (watch.Interface, error) { watchFunc := func(resourceVersion string) (watch.Interface, error) {
return c.Get().Prefix("watch").Namespace(namespace).Resource(resource).SelectorParam(api.FieldSelectorQueryParam(c.APIVersion()), fieldSelector).Param("resourceVersion", resourceVersion).Watch() return c.Get().Prefix("watch").Namespace(namespace).Resource(resource).FieldsSelectorParam(api.FieldSelectorQueryParam(c.APIVersion()), fieldSelector).Param("resourceVersion", resourceVersion).Watch()
} }
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc} return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
} }

View File

@ -25,12 +25,12 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
) )
func parseSelectorOrDie(s string) labels.Selector { func parseSelectorOrDie(s string) fields.Selector {
selector, err := labels.Parse(s) selector, err := fields.ParseSelector(s)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -82,7 +82,7 @@ func TestListWatchesCanList(t *testing.T) {
location string location string
resource string resource string
namespace string namespace string
fieldSelector labels.Selector fieldSelector fields.Selector
}{ }{
// Minion // Minion
{ {
@ -96,14 +96,14 @@ func TestListWatchesCanList(t *testing.T) {
location: buildLocation(buildResourcePath("", api.NamespaceAll, "pods"), buildQueryValues(api.NamespaceAll, url.Values{"fields": []string{getHostFieldLabel() + "="}})), location: buildLocation(buildResourcePath("", api.NamespaceAll, "pods"), buildQueryValues(api.NamespaceAll, url.Values{"fields": []string{getHostFieldLabel() + "="}})),
resource: "pods", resource: "pods",
namespace: api.NamespaceAll, namespace: api.NamespaceAll,
fieldSelector: labels.Set{getHostFieldLabel(): ""}.AsSelector(), fieldSelector: fields.Set{getHostFieldLabel(): ""}.AsSelector(),
}, },
// pod in namespace "foo" // pod in namespace "foo"
{ {
location: buildLocation(buildResourcePath("", "foo", "pods"), buildQueryValues("foo", url.Values{"fields": []string{getHostFieldLabel() + "="}})), location: buildLocation(buildResourcePath("", "foo", "pods"), buildQueryValues("foo", url.Values{"fields": []string{getHostFieldLabel() + "="}})),
resource: "pods", resource: "pods",
namespace: "foo", namespace: "foo",
fieldSelector: labels.Set{getHostFieldLabel(): ""}.AsSelector(), fieldSelector: fields.Set{getHostFieldLabel(): ""}.AsSelector(),
}, },
} }
for _, item := range table { for _, item := range table {
@ -128,7 +128,7 @@ func TestListWatchesCanWatch(t *testing.T) {
location string location string
resource string resource string
namespace string namespace string
fieldSelector labels.Selector fieldSelector fields.Selector
}{ }{
// Minion // Minion
{ {
@ -151,7 +151,7 @@ func TestListWatchesCanWatch(t *testing.T) {
rv: "0", rv: "0",
resource: "pods", resource: "pods",
namespace: api.NamespaceAll, namespace: api.NamespaceAll,
fieldSelector: labels.Set{getHostFieldLabel(): ""}.AsSelector(), fieldSelector: fields.Set{getHostFieldLabel(): ""}.AsSelector(),
}, },
// pod with namespace foo and assigned field selector // pod with namespace foo and assigned field selector
{ {
@ -159,7 +159,7 @@ func TestListWatchesCanWatch(t *testing.T) {
rv: "0", rv: "0",
resource: "pods", resource: "pods",
namespace: "foo", namespace: "foo",
fieldSelector: labels.Set{getHostFieldLabel(): ""}.AsSelector(), fieldSelector: fields.Set{getHostFieldLabel(): ""}.AsSelector(),
}, },
} }

View File

@ -30,6 +30,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@ -241,8 +242,8 @@ func validateLabels(a, b string) bool {
} }
func validateFields(a, b string) bool { func validateFields(a, b string) bool {
sA, _ := labels.ParseSelector(a) sA, _ := fields.ParseSelector(a)
sB, _ := labels.ParseSelector(b) sB, _ := fields.ParseSelector(b)
return sA.String() == sB.String() return sA.String() == sB.String()
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -36,7 +37,7 @@ type EndpointsInterface interface {
List(selector labels.Selector) (*api.EndpointsList, error) List(selector labels.Selector) (*api.EndpointsList, error)
Get(name string) (*api.Endpoints, error) Get(name string) (*api.Endpoints, error)
Update(endpoints *api.Endpoints) (*api.Endpoints, error) Update(endpoints *api.Endpoints) (*api.Endpoints, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// endpoints implements EndpointsInterface // endpoints implements EndpointsInterface
@ -63,7 +64,7 @@ func (c *endpoints) List(selector labels.Selector) (result *api.EndpointsList, e
err = c.r.Get(). err = c.r.Get().
Namespace(c.ns). Namespace(c.ns).
Resource("endpoints"). Resource("endpoints").
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).
Do(). Do().
Into(result) Into(result)
return return
@ -81,14 +82,14 @@ func (c *endpoints) Get(name string) (result *api.Endpoints, err error) {
} }
// Watch returns a watch.Interface that watches the requested endpoints for a service. // Watch returns a watch.Interface that watches the requested endpoints for a service.
func (c *endpoints) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *endpoints) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Namespace(c.ns). Namespace(c.ns).
Resource("endpoints"). Resource("endpoints").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -35,9 +36,9 @@ type EventNamespacer interface {
type EventInterface interface { type EventInterface interface {
Create(event *api.Event) (*api.Event, error) Create(event *api.Event) (*api.Event, error)
Update(event *api.Event) (*api.Event, error) Update(event *api.Event) (*api.Event, error)
List(label, field labels.Selector) (*api.EventList, error) List(label labels.Selector, field fields.Selector) (*api.EventList, error)
Get(name string) (*api.Event, error) Get(name string) (*api.Event, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
// Search finds events about the specified object // Search finds events about the specified object
Search(objOrRef runtime.Object) (*api.EventList, error) Search(objOrRef runtime.Object) (*api.EventList, error)
Delete(name string) error Delete(name string) error
@ -96,13 +97,13 @@ func (e *events) Update(event *api.Event) (*api.Event, error) {
} }
// List returns a list of events matching the selectors. // List returns a list of events matching the selectors.
func (e *events) List(label, field labels.Selector) (*api.EventList, error) { func (e *events) List(label labels.Selector, field fields.Selector) (*api.EventList, error) {
result := &api.EventList{} result := &api.EventList{}
err := e.client.Get(). err := e.client.Get().
NamespaceIfScoped(e.namespace, len(e.namespace) > 0). NamespaceIfScoped(e.namespace, len(e.namespace) > 0).
Resource("events"). Resource("events").
SelectorParam(api.LabelSelectorQueryParam(e.client.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(e.client.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(e.client.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(e.client.APIVersion()), field).
Do(). Do().
Into(result) Into(result)
return result, err return result, err
@ -125,14 +126,14 @@ func (e *events) Get(name string) (*api.Event, error) {
} }
// Watch starts watching for events matching the given selectors. // Watch starts watching for events matching the given selectors.
func (e *events) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (e *events) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return e.client.Get(). return e.client.Get().
Prefix("watch"). Prefix("watch").
NamespaceIfScoped(e.namespace, len(e.namespace) > 0). NamespaceIfScoped(e.namespace, len(e.namespace) > 0).
Resource("events"). Resource("events").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(e.client.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(e.client.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(e.client.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(e.client.APIVersion()), field).
Watch() Watch()
} }
@ -147,7 +148,7 @@ func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) {
if e.namespace != "" && ref.Namespace != e.namespace { if e.namespace != "" && ref.Namespace != e.namespace {
return nil, fmt.Errorf("won't be able to find any events of namespace '%v' in namespace '%v'", ref.Namespace, e.namespace) return nil, fmt.Errorf("won't be able to find any events of namespace '%v' in namespace '%v'", ref.Namespace, e.namespace)
} }
fields := labels.Set{} fields := fields.Set{}
if ref.Kind != "" { if ref.Kind != "" {
fields["involvedObject.kind"] = ref.Kind fields["involvedObject.kind"] = ref.Kind
} }

View File

@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
) )
@ -159,7 +160,7 @@ func TestEventList(t *testing.T) {
Response: Response{StatusCode: 200, Body: eventList}, Response: Response{StatusCode: 200, Body: eventList},
} }
response, err := c.Setup().Events(ns).List(labels.Everything(), response, err := c.Setup().Events(ns).List(labels.Everything(),
labels.Everything()) fields.Everything())
if err != nil { if err != nil {
t.Errorf("%#v should be nil.", err) t.Errorf("%#v should be nil.", err)

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -44,7 +45,7 @@ func (c *FakeEndpoints) Get(name string) (*api.Endpoints, error) {
return &api.Endpoints{}, nil return &api.Endpoints{}, nil
} }
func (c *FakeEndpoints) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeEndpoints) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-endpoints", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-endpoints", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err return c.Fake.Watch, c.Fake.Err
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -42,7 +43,7 @@ func (c *FakeEvents) Update(event *api.Event) (*api.Event, error) {
} }
// List returns a list of events matching the selectors. // List returns a list of events matching the selectors.
func (c *FakeEvents) List(label, field labels.Selector) (*api.EventList, error) { func (c *FakeEvents) List(label labels.Selector, field fields.Selector) (*api.EventList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-events"}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-events"})
return &c.Fake.EventsList, nil return &c.Fake.EventsList, nil
} }
@ -54,7 +55,7 @@ func (c *FakeEvents) Get(id string) (*api.Event, error) {
} }
// Watch starts watching for events matching the given selectors. // Watch starts watching for events matching the given selectors.
func (c *FakeEvents) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeEvents) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-events", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-events", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err return c.Fake.Watch, c.Fake.Err
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -54,7 +55,7 @@ func (c *FakeLimitRanges) Update(limitRange *api.LimitRange) (*api.LimitRange, e
return &api.LimitRange{}, nil return &api.LimitRange{}, nil
} }
func (c *FakeLimitRanges) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeLimitRanges) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-limitRange", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-limitRange", Value: resourceVersion})
return c.Fake.Watch, nil return c.Fake.Watch, nil
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -53,7 +54,7 @@ func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error
return &api.Namespace{}, nil return &api.Namespace{}, nil
} }
func (c *FakeNamespaces) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-namespaces", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-namespaces", Value: resourceVersion})
return c.Fake.Watch, nil return c.Fake.Watch, nil
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -54,7 +55,7 @@ func (c *FakePods) Update(pod *api.Pod) (*api.Pod, error) {
return &api.Pod{}, nil return &api.Pod{}, nil
} }
func (c *FakePods) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakePods) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-pods", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-pods", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err return c.Fake.Watch, c.Fake.Err
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -54,7 +55,7 @@ func (c *FakeReplicationControllers) Delete(controller string) error {
return nil return nil
} }
func (c *FakeReplicationControllers) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeReplicationControllers) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-controllers", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-controllers", Value: resourceVersion})
return c.Fake.Watch, nil return c.Fake.Watch, nil
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -60,7 +61,7 @@ func (c *FakeResourceQuotas) Status(resourceQuota *api.ResourceQuota) (*api.Reso
return &api.ResourceQuota{}, nil return &api.ResourceQuota{}, nil
} }
func (c *FakeResourceQuotas) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeResourceQuotas) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-resourceQuota", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-resourceQuota", Value: resourceVersion})
return c.Fake.Watch, nil return c.Fake.Watch, nil
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -29,7 +30,7 @@ type FakeSecrets struct {
Namespace string Namespace string
} }
func (c *FakeSecrets) List(labels, fields labels.Selector) (*api.SecretList, error) { func (c *FakeSecrets) List(labels labels.Selector, field fields.Selector) (*api.SecretList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-secrets"}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-secrets"})
return &c.Fake.SecretList, c.Fake.Err return &c.Fake.SecretList, c.Fake.Err
} }
@ -54,7 +55,7 @@ func (c *FakeSecrets) Delete(secret string) error {
return nil return nil
} }
func (c *FakeSecrets) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeSecrets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-secrets", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-secrets", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err return c.Fake.Watch, c.Fake.Err
} }

View File

@ -18,6 +18,7 @@ package client
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -54,7 +55,7 @@ func (c *FakeServices) Delete(service string) error {
return nil return nil
} }
func (c *FakeServices) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *FakeServices) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-services", Value: resourceVersion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-services", Value: resourceVersion})
return c.Fake.Watch, c.Fake.Err return c.Fake.Watch, c.Fake.Err
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -37,7 +38,7 @@ type LimitRangeInterface interface {
Delete(name string) error Delete(name string) error
Create(limitRange *api.LimitRange) (*api.LimitRange, error) Create(limitRange *api.LimitRange) (*api.LimitRange, error)
Update(limitRange *api.LimitRange) (*api.LimitRange, error) Update(limitRange *api.LimitRange) (*api.LimitRange, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// limitRanges implements LimitRangesNamespacer interface // limitRanges implements LimitRangesNamespacer interface
@ -57,7 +58,7 @@ func newLimitRanges(c *Client, namespace string) *limitRanges {
// List takes a selector, and returns the list of limitRanges that match that selector. // List takes a selector, and returns the list of limitRanges that match that selector.
func (c *limitRanges) List(selector labels.Selector) (result *api.LimitRangeList, err error) { func (c *limitRanges) List(selector labels.Selector) (result *api.LimitRangeList, err error) {
result = &api.LimitRangeList{} result = &api.LimitRangeList{}
err = c.r.Get().Namespace(c.ns).Resource("limitRanges").SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result) err = c.r.Get().Namespace(c.ns).Resource("limitRanges").LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result)
return return
} }
@ -96,13 +97,13 @@ func (c *limitRanges) Update(limitRange *api.LimitRange) (result *api.LimitRange
} }
// Watch returns a watch.Interface that watches the requested resource // Watch returns a watch.Interface that watches the requested resource
func (c *limitRanges) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *limitRanges) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Namespace(c.ns). Namespace(c.ns).
Resource("limitRanges"). Resource("limitRanges").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
) )
@ -198,6 +199,6 @@ func TestLimitRangeWatch(t *testing.T) {
Request: testRequest{Method: "GET", Path: "/watch/limitRanges", Query: url.Values{"resourceVersion": []string{}}}, Request: testRequest{Method: "GET", Path: "/watch/limitRanges", Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200}, Response: Response{StatusCode: 200},
} }
_, err := c.Setup().LimitRanges(api.NamespaceAll).Watch(labels.Everything(), labels.Everything(), "") _, err := c.Setup().LimitRanges(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), "")
c.Validate(t, nil, err) c.Validate(t, nil, err)
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -35,7 +36,7 @@ type NamespaceInterface interface {
List(selector labels.Selector) (*api.NamespaceList, error) List(selector labels.Selector) (*api.NamespaceList, error)
Delete(name string) error Delete(name string) error
Update(item *api.Namespace) (*api.Namespace, error) Update(item *api.Namespace) (*api.Namespace, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// namespaces implements NamespacesInterface // namespaces implements NamespacesInterface
@ -58,7 +59,7 @@ func (c *namespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
// List lists all the namespaces in the cluster. // List lists all the namespaces in the cluster.
func (c *namespaces) List(selector labels.Selector) (*api.NamespaceList, error) { func (c *namespaces) List(selector labels.Selector) (*api.NamespaceList, error) {
result := &api.NamespaceList{} result := &api.NamespaceList{}
err := c.r.Get().Resource("namespaces").SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result) err := c.r.Get().Resource("namespaces").LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result)
return result, err return result, err
} }
@ -90,12 +91,12 @@ func (c *namespaces) Delete(name string) error {
} }
// Watch returns a watch.Interface that watches the requested namespaces. // Watch returns a watch.Interface that watches the requested namespaces.
func (c *namespaces) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *namespaces) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Resource("namespaces"). Resource("namespaces").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -21,6 +21,7 @@ import (
"testing" "testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
) )
@ -139,6 +140,6 @@ func TestNamespaceWatch(t *testing.T) {
Request: testRequest{Method: "GET", Path: "/watch/namespaces", Query: url.Values{"resourceVersion": []string{}}}, Request: testRequest{Method: "GET", Path: "/watch/namespaces", Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200}, Response: Response{StatusCode: 200},
} }
_, err := c.Setup().Namespaces().Watch(labels.Everything(), labels.Everything(), "") _, err := c.Setup().Namespaces().Watch(labels.Everything(), fields.Everything(), "")
c.Validate(t, nil, err) c.Validate(t, nil, err)
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -37,7 +38,7 @@ type PodInterface interface {
Delete(name string) error Delete(name string) error
Create(pod *api.Pod) (*api.Pod, error) Create(pod *api.Pod) (*api.Pod, error)
Update(pod *api.Pod) (*api.Pod, error) Update(pod *api.Pod) (*api.Pod, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
Bind(binding *api.Binding) error Bind(binding *api.Binding) error
} }
@ -58,7 +59,7 @@ func newPods(c *Client, namespace string) *pods {
// List takes a selector, and returns the list of pods that match that selector. // List takes a selector, and returns the list of pods that match that selector.
func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) { func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) {
result = &api.PodList{} result = &api.PodList{}
err = c.r.Get().Namespace(c.ns).Resource("pods").SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result) err = c.r.Get().Namespace(c.ns).Resource("pods").LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result)
return return
} }
@ -97,14 +98,14 @@ func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) {
} }
// Watch returns a watch.Interface that watches the requested pods. // Watch returns a watch.Interface that watches the requested pods.
func (c *pods) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *pods) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Namespace(c.ns). Namespace(c.ns).
Resource("pods"). Resource("pods").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam("labels", label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam("fields", field). FieldsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -37,7 +38,7 @@ type ReplicationControllerInterface interface {
Create(ctrl *api.ReplicationController) (*api.ReplicationController, error) Create(ctrl *api.ReplicationController) (*api.ReplicationController, error)
Update(ctrl *api.ReplicationController) (*api.ReplicationController, error) Update(ctrl *api.ReplicationController) (*api.ReplicationController, error)
Delete(name string) error Delete(name string) error
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// replicationControllers implements ReplicationControllersNamespacer interface // replicationControllers implements ReplicationControllersNamespacer interface
@ -54,7 +55,7 @@ func newReplicationControllers(c *Client, namespace string) *replicationControll
// List takes a selector, and returns the list of replication controllers that match that selector. // List takes a selector, and returns the list of replication controllers that match that selector.
func (c *replicationControllers) List(selector labels.Selector) (result *api.ReplicationControllerList, err error) { func (c *replicationControllers) List(selector labels.Selector) (result *api.ReplicationControllerList, err error) {
result = &api.ReplicationControllerList{} result = &api.ReplicationControllerList{}
err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result) err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result)
return return
} }
@ -93,13 +94,13 @@ func (c *replicationControllers) Delete(name string) error {
} }
// Watch returns a watch.Interface that watches the requested controllers. // Watch returns a watch.Interface that watches the requested controllers.
func (c *replicationControllers) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *replicationControllers) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Namespace(c.ns). Namespace(c.ns).
Resource("replicationControllers"). Resource("replicationControllers").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -288,8 +288,19 @@ func (r *Request) ParseSelectorParam(paramName, item string) *Request {
return r.setParam(paramName, selector) return r.setParam(paramName, selector)
} }
// SelectorParam adds the given selector as a query parameter with the name paramName. // FieldsSelectorParam adds the given selector as a query parameter with the name paramName.
func (r *Request) SelectorParam(paramName string, s labels.Selector) *Request { func (r *Request) FieldsSelectorParam(paramName string, s fields.Selector) *Request {
if r.err != nil {
return r
}
if s.Empty() {
return r
}
return r.setParam(paramName, s.String())
}
// LabelsSelectorParam adds the given selector as a query parameter
func (r *Request) LabelsSelectorParam(paramName string, s labels.Selector) *Request {
if r.err != nil { if r.err != nil {
return r return r
} }

View File

@ -50,7 +50,7 @@ func TestRequestWithErrorWontChange(t *testing.T) {
original := Request{err: errors.New("test")} original := Request{err: errors.New("test")}
r := original r := original
changed := r.Param("foo", "bar"). changed := r.Param("foo", "bar").
SelectorParam(api.LabelSelectorQueryParam(testapi.Version()), labels.Set{"a": "b"}.AsSelector()). LabelsSelectorParam(api.LabelSelectorQueryParam(testapi.Version()), labels.Set{"a": "b"}.AsSelector()).
UintParam("uint", 1). UintParam("uint", 1).
AbsPath("/abs"). AbsPath("/abs").
Prefix("test"). Prefix("test").
@ -664,7 +664,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
Resource("bar"). Resource("bar").
Name("baz"). Name("baz").
Prefix("foo"). Prefix("foo").
SelectorParam(api.LabelSelectorQueryParam(c.APIVersion()), labels.Set{"name": "foo"}.AsSelector()). LabelsSelectorParam(api.LabelSelectorQueryParam(c.APIVersion()), labels.Set{"name": "foo"}.AsSelector()).
Timeout(time.Second). Timeout(time.Second).
Body(bytes.NewBuffer(reqBodyExpected)). Body(bytes.NewBuffer(reqBodyExpected)).
Do().Get() Do().Get()
@ -700,7 +700,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
Suffix("baz"). Suffix("baz").
Name("bar"). Name("bar").
Resource("foo"). Resource("foo").
SelectorParam(api.LabelSelectorQueryParam(c.APIVersion()), labels.Set{"name": "foo"}.AsSelector()). LabelsSelectorParam(api.LabelSelectorQueryParam(c.APIVersion()), labels.Set{"name": "foo"}.AsSelector()).
Timeout(time.Second). Timeout(time.Second).
Body(reqObj). Body(reqObj).
Do().Get() Do().Get()

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -38,7 +39,7 @@ type ResourceQuotaInterface interface {
Create(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) Create(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)
Update(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) Update(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)
Status(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) Status(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// resourceQuotas implements ResourceQuotasNamespacer interface // resourceQuotas implements ResourceQuotasNamespacer interface
@ -58,7 +59,7 @@ func newResourceQuotas(c *Client, namespace string) *resourceQuotas {
// List takes a selector, and returns the list of resourceQuotas that match that selector. // List takes a selector, and returns the list of resourceQuotas that match that selector.
func (c *resourceQuotas) List(selector labels.Selector) (result *api.ResourceQuotaList, err error) { func (c *resourceQuotas) List(selector labels.Selector) (result *api.ResourceQuotaList, err error) {
result = &api.ResourceQuotaList{} result = &api.ResourceQuotaList{}
err = c.r.Get().Namespace(c.ns).Resource("resourceQuotas").SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result) err = c.r.Get().Namespace(c.ns).Resource("resourceQuotas").LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).Do().Into(result)
return return
} }
@ -108,13 +109,13 @@ func (c *resourceQuotas) Status(resourceQuota *api.ResourceQuota) (result *api.R
} }
// Watch returns a watch.Interface that watches the requested resource // Watch returns a watch.Interface that watches the requested resource
func (c *resourceQuotas) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *resourceQuotas) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Namespace(c.ns). Namespace(c.ns).
Resource("resourceQuotas"). Resource("resourceQuotas").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
) )
@ -209,6 +210,6 @@ func TestResourceQuotaWatch(t *testing.T) {
Request: testRequest{Method: "GET", Path: "/watch/resourceQuotas", Query: url.Values{"resourceVersion": []string{}}}, Request: testRequest{Method: "GET", Path: "/watch/resourceQuotas", Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200}, Response: Response{StatusCode: 200},
} }
_, err := c.Setup().ResourceQuotas(api.NamespaceAll).Watch(labels.Everything(), labels.Everything(), "") _, err := c.Setup().ResourceQuotas(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), "")
c.Validate(t, nil, err) c.Validate(t, nil, err)
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -33,9 +34,9 @@ type SecretsInterface interface {
Create(secret *api.Secret) (*api.Secret, error) Create(secret *api.Secret) (*api.Secret, error)
Update(secret *api.Secret) (*api.Secret, error) Update(secret *api.Secret) (*api.Secret, error)
Delete(name string) error Delete(name string) error
List(label, field labels.Selector) (*api.SecretList, error) List(label labels.Selector, field fields.Selector) (*api.SecretList, error)
Get(name string) (*api.Secret, error) Get(name string) (*api.Secret, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// events implements Secrets interface // events implements Secrets interface
@ -69,14 +70,14 @@ func (s *secrets) Create(secret *api.Secret) (*api.Secret, error) {
} }
// List returns a list of secrets matching the selectors. // List returns a list of secrets matching the selectors.
func (s *secrets) List(label, field labels.Selector) (*api.SecretList, error) { func (s *secrets) List(label labels.Selector, field fields.Selector) (*api.SecretList, error) {
result := &api.SecretList{} result := &api.SecretList{}
err := s.client.Get(). err := s.client.Get().
Namespace(s.namespace). Namespace(s.namespace).
Resource("secrets"). Resource("secrets").
SelectorParam(api.LabelSelectorQueryParam(s.client.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(s.client.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(s.client.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(s.client.APIVersion()), field).
Do(). Do().
Into(result) Into(result)
@ -101,14 +102,14 @@ func (s *secrets) Get(name string) (*api.Secret, error) {
} }
// Watch starts watching for secrets matching the given selectors. // Watch starts watching for secrets matching the given selectors.
func (s *secrets) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (s *secrets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return s.client.Get(). return s.client.Get().
Prefix("watch"). Prefix("watch").
Namespace(s.namespace). Namespace(s.namespace).
Resource("secrets"). Resource("secrets").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(s.client.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(s.client.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(s.client.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(s.client.APIVersion()), field).
Watch() Watch()
} }

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -37,7 +38,7 @@ type ServiceInterface interface {
Create(srv *api.Service) (*api.Service, error) Create(srv *api.Service) (*api.Service, error)
Update(srv *api.Service) (*api.Service, error) Update(srv *api.Service) (*api.Service, error)
Delete(name string) error Delete(name string) error
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// services implements PodsNamespacer interface // services implements PodsNamespacer interface
@ -57,7 +58,7 @@ func (c *services) List(selector labels.Selector) (result *api.ServiceList, err
err = c.r.Get(). err = c.r.Get().
Namespace(c.ns). Namespace(c.ns).
Resource("services"). Resource("services").
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), selector).
Do(). Do().
Into(result) Into(result)
return return
@ -98,13 +99,13 @@ func (c *services) Delete(name string) error {
} }
// Watch returns a watch.Interface that watches the requested services. // Watch returns a watch.Interface that watches the requested services.
func (c *services) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { func (c *services) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get(). return c.r.Get().
Prefix("watch"). Prefix("watch").
Namespace(c.ns). Namespace(c.ns).
Resource("services"). Resource("services").
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label). LabelsSelectorParam(api.LabelSelectorQueryParam(c.r.APIVersion()), label).
SelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field). FieldsSelectorParam(api.FieldSelectorQueryParam(c.r.APIVersion()), field).
Watch() Watch()
} }

View File

@ -25,6 +25,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -122,7 +123,7 @@ func (rm *ReplicationManager) Run(period time.Duration) {
func (rm *ReplicationManager) watchControllers(resourceVersion *string) { func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
watching, err := rm.kubeClient.ReplicationControllers(api.NamespaceAll).Watch( watching, err := rm.kubeClient.ReplicationControllers(api.NamespaceAll).Watch(
labels.Everything(), labels.Everything(),
labels.Everything(), fields.Everything(),
*resourceVersion, *resourceVersion,
) )
if err != nil { if err != nil {

View File

@ -26,6 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/golang/glog" "github.com/golang/glog"
) )
@ -205,7 +206,7 @@ func (d *PodDescriber) Describe(namespace, name string) (string, error) {
if err != nil { if err != nil {
events, err2 := d.Events(namespace).List( events, err2 := d.Events(namespace).List(
labels.Everything(), labels.Everything(),
labels.Set{ fields.Set{
"involvedObject.name": name, "involvedObject.name": name,
"involvedObject.namespace": namespace, "involvedObject.namespace": namespace,
}.AsSelector(), }.AsSelector(),

View File

@ -19,6 +19,7 @@ package resource
import ( import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -65,19 +66,19 @@ func (m *Helper) List(namespace, apiVersion string, selector labels.Selector) (r
return m.RESTClient.Get(). return m.RESTClient.Get().
NamespaceIfScoped(namespace, m.NamespaceScoped). NamespaceIfScoped(namespace, m.NamespaceScoped).
Resource(m.Resource). Resource(m.Resource).
SelectorParam(api.LabelSelectorQueryParam(apiVersion), selector). LabelsSelectorParam(api.LabelSelectorQueryParam(apiVersion), selector).
Do(). Do().
Get() Get()
} }
func (m *Helper) Watch(namespace, resourceVersion, apiVersion string, labelSelector, fieldSelector labels.Selector) (watch.Interface, error) { func (m *Helper) Watch(namespace, resourceVersion, apiVersion string, labelSelector labels.Selector, fieldSelector fields.Selector) (watch.Interface, error) {
return m.RESTClient.Get(). return m.RESTClient.Get().
Prefix("watch"). Prefix("watch").
NamespaceIfScoped(namespace, m.NamespaceScoped). NamespaceIfScoped(namespace, m.NamespaceScoped).
Resource(m.Resource). Resource(m.Resource).
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
SelectorParam(api.LabelSelectorQueryParam(apiVersion), labelSelector). LabelsSelectorParam(api.LabelSelectorQueryParam(apiVersion), labelSelector).
SelectorParam(api.FieldSelectorQueryParam(apiVersion), fieldSelector). FieldsSelectorParam(api.FieldSelectorQueryParam(apiVersion), fieldSelector).
Watch() Watch()
} }

View File

@ -21,6 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
@ -71,7 +72,7 @@ func (r *Selector) Visit(fn VisitorFunc) error {
} }
func (r *Selector) Watch(resourceVersion string) (watch.Interface, error) { func (r *Selector) Watch(resourceVersion string) (watch.Interface, error) {
return NewHelper(r.Client, r.Mapping).Watch(r.Namespace, resourceVersion, r.ResourceMapping().APIVersion, r.Selector, labels.Everything()) return NewHelper(r.Client, r.Mapping).Watch(r.Namespace, resourceVersion, r.ResourceMapping().APIVersion, r.Selector, fields.Everything())
} }
// ResourceMapping returns the mapping for this resource and implements ResourceMapping // ResourceMapping returns the mapping for this resource and implements ResourceMapping

View File

@ -21,13 +21,13 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
) )
// NewSourceApiserver creates a config source that watches and pulls from the apiserver. // NewSourceApiserver creates a config source that watches and pulls from the apiserver.
func NewSourceApiserver(client *client.Client, hostname string, updates chan<- interface{}) { func NewSourceApiserver(client *client.Client, hostname string, updates chan<- interface{}) {
lw := cache.NewListWatchFromClient(client, "pods", api.NamespaceAll, labels.OneTermEqualSelector(getHostFieldLabel(client.APIVersion()), hostname)) lw := cache.NewListWatchFromClient(client, "pods", api.NamespaceAll, fields.OneTermEqualSelector(getHostFieldLabel(client.APIVersion()), hostname))
newSourceApiserverFromLW(lw, updates) newSourceApiserverFromLW(lw, updates)
} }

View File

@ -38,6 +38,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
@ -157,7 +158,7 @@ func NewMainKubelet(
return kubeClient.Services(api.NamespaceAll).List(labels.Everything()) return kubeClient.Services(api.NamespaceAll).List(labels.Everything())
}, },
WatchFunc: func(resourceVersion string) (watch.Interface, error) { WatchFunc: func(resourceVersion string) (watch.Interface, error) {
return kubeClient.Services(api.NamespaceAll).Watch(labels.Everything(), labels.Everything(), resourceVersion) return kubeClient.Services(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), resourceVersion)
}, },
} }
cache.NewReflector(listWatch, &api.Service{}, serviceStore, 0).Run() cache.NewReflector(listWatch, &api.Service{}, serviceStore, 0).Run()

View File

@ -21,6 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
@ -32,13 +33,13 @@ import (
// ServicesWatcher is capable of listing and watching for changes to services across ALL namespaces // ServicesWatcher is capable of listing and watching for changes to services across ALL namespaces
type ServicesWatcher interface { type ServicesWatcher interface {
List(label labels.Selector) (*api.ServiceList, error) List(label labels.Selector) (*api.ServiceList, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// EndpointsWatcher is capable of listing and watching for changes to endpoints across ALL namespaces // EndpointsWatcher is capable of listing and watching for changes to endpoints across ALL namespaces
type EndpointsWatcher interface { type EndpointsWatcher interface {
List(label labels.Selector) (*api.EndpointsList, error) List(label labels.Selector) (*api.EndpointsList, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
} }
// SourceAPI implements a configuration source for services and endpoints that // SourceAPI implements a configuration source for services and endpoints that
@ -114,7 +115,7 @@ func (s *servicesReflector) run(resourceVersion *string) {
s.services <- ServiceUpdate{Op: SET, Services: services.Items} s.services <- ServiceUpdate{Op: SET, Services: services.Items}
} }
watcher, err := s.watcher.Watch(labels.Everything(), labels.Everything(), *resourceVersion) watcher, err := s.watcher.Watch(labels.Everything(), fields.Everything(), *resourceVersion)
if err != nil { if err != nil {
glog.Errorf("Unable to watch for services changes: %v", err) glog.Errorf("Unable to watch for services changes: %v", err)
if !client.IsTimeout(err) { if !client.IsTimeout(err) {
@ -184,7 +185,7 @@ func (s *endpointsReflector) run(resourceVersion *string) {
s.endpoints <- EndpointsUpdate{Op: SET, Endpoints: endpoints.Items} s.endpoints <- EndpointsUpdate{Op: SET, Endpoints: endpoints.Items}
} }
watcher, err := s.watcher.Watch(labels.Everything(), labels.Everything(), *resourceVersion) watcher, err := s.watcher.Watch(labels.Everything(), fields.Everything(), *resourceVersion)
if err != nil { if err != nil {
glog.Errorf("Unable to watch for endpoints changes: %v", err) glog.Errorf("Unable to watch for endpoints changes: %v", err)
if !client.IsTimeout(err) { if !client.IsTimeout(err) {

View File

@ -27,6 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -91,7 +92,7 @@ func NewLimitRanger(client client.Interface, limitFunc LimitFunc) admission.Inte
return client.LimitRanges(api.NamespaceAll).List(labels.Everything()) return client.LimitRanges(api.NamespaceAll).List(labels.Everything())
}, },
WatchFunc: func(resourceVersion string) (watch.Interface, error) { WatchFunc: func(resourceVersion string) (watch.Interface, error) {
return client.LimitRanges(api.NamespaceAll).Watch(labels.Everything(), labels.Everything(), resourceVersion) return client.LimitRanges(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), resourceVersion)
}, },
} }
indexer, reflector := cache.NewNamespaceKeyedIndexerAndReflector(lw, &api.LimitRange{}, 0) indexer, reflector := cache.NewNamespaceKeyedIndexerAndReflector(lw, &api.LimitRange{}, 0)

View File

@ -25,6 +25,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -89,7 +90,7 @@ func NewProvision(c client.Interface) admission.Interface {
return c.Namespaces().List(labels.Everything()) return c.Namespaces().List(labels.Everything())
}, },
WatchFunc: func(resourceVersion string) (watch.Interface, error) { WatchFunc: func(resourceVersion string) (watch.Interface, error) {
return c.Namespaces().Watch(labels.Everything(), labels.Everything(), resourceVersion) return c.Namespaces().Watch(labels.Everything(), fields.Everything(), resourceVersion)
}, },
}, },
&api.Namespace{}, &api.Namespace{},

View File

@ -27,6 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -88,7 +89,7 @@ func NewExists(c client.Interface) admission.Interface {
return c.Namespaces().List(labels.Everything()) return c.Namespaces().List(labels.Everything())
}, },
WatchFunc: func(resourceVersion string) (watch.Interface, error) { WatchFunc: func(resourceVersion string) (watch.Interface, error) {
return c.Namespaces().Watch(labels.Everything(), labels.Everything(), resourceVersion) return c.Namespaces().Watch(labels.Everything(), fields.Everything(), resourceVersion)
}, },
}, },
&api.Namespace{}, &api.Namespace{},

View File

@ -27,6 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/resourcequota" "github.com/GoogleCloudPlatform/kubernetes/pkg/resourcequota"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
@ -50,7 +51,7 @@ func NewResourceQuota(client client.Interface) admission.Interface {
return client.ResourceQuotas(api.NamespaceAll).List(labels.Everything()) return client.ResourceQuotas(api.NamespaceAll).List(labels.Everything())
}, },
WatchFunc: func(resourceVersion string) (watch.Interface, error) { WatchFunc: func(resourceVersion string) (watch.Interface, error) {
return client.ResourceQuotas(api.NamespaceAll).Watch(labels.Everything(), labels.Everything(), resourceVersion) return client.ResourceQuotas(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), resourceVersion)
}, },
} }
indexer, reflector := cache.NewNamespaceKeyedIndexerAndReflector(lw, &api.ResourceQuota{}, 0) indexer, reflector := cache.NewNamespaceKeyedIndexerAndReflector(lw, &api.ResourceQuota{}, 0)

View File

@ -27,7 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
algorithm "github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler" algorithm "github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler" "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler"
@ -174,11 +174,11 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys util.StringSe
// Returns a cache.ListWatch that finds all pods that need to be // Returns a cache.ListWatch that finds all pods that need to be
// scheduled. // scheduled.
func (factory *ConfigFactory) createUnassignedPodLW() *cache.ListWatch { func (factory *ConfigFactory) createUnassignedPodLW() *cache.ListWatch {
return cache.NewListWatchFromClient(factory.Client, "pods", api.NamespaceAll, labels.Set{getHostFieldLabel(factory.Client.APIVersion()): ""}.AsSelector()) return cache.NewListWatchFromClient(factory.Client, "pods", api.NamespaceAll, fields.Set{getHostFieldLabel(factory.Client.APIVersion()): ""}.AsSelector())
} }
func parseSelectorOrDie(s string) labels.Selector { func parseSelectorOrDie(s string) fields.Selector {
selector, err := labels.ParseSelector(s) selector, err := fields.ParseSelector(s)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@ -96,7 +97,7 @@ var _ = Describe("Events", func() {
By("checking for scheduler event about the pod") By("checking for scheduler event about the pod")
events, err := c.Events(api.NamespaceDefault).List( events, err := c.Events(api.NamespaceDefault).List(
labels.Everything(), labels.Everything(),
labels.Set{ fields.Set{
"involvedObject.kind": "Pod", "involvedObject.kind": "Pod",
"involvedObject.uid": string(podWithUid.UID), "involvedObject.uid": string(podWithUid.UID),
"involvedObject.namespace": api.NamespaceDefault, "involvedObject.namespace": api.NamespaceDefault,
@ -113,7 +114,7 @@ var _ = Describe("Events", func() {
By("checking for kubelet event about the pod") By("checking for kubelet event about the pod")
events, err = c.Events(api.NamespaceDefault).List( events, err = c.Events(api.NamespaceDefault).List(
labels.Everything(), labels.Everything(),
labels.Set{ fields.Set{
"involvedObject.uid": string(podWithUid.UID), "involvedObject.uid": string(podWithUid.UID),
"involvedObject.kind": "Pod", "involvedObject.kind": "Pod",
"involvedObject.namespace": api.NamespaceDefault, "involvedObject.namespace": api.NamespaceDefault,

View File

@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@ -130,7 +131,7 @@ var _ = Describe("Pods", func() {
} }
Expect(len(pods.Items)).To(Equal(0)) Expect(len(pods.Items)).To(Equal(0))
w, err := podClient.Watch( w, err := podClient.Watch(
labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), labels.Everything(), pods.ListMeta.ResourceVersion) labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything(), pods.ListMeta.ResourceVersion)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to set up watch: %v", err)) Fail(fmt.Sprintf("Failed to set up watch: %v", err))
} }