Skip to content

Commit

Permalink
Simplify Watch() signature in clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-t committed Dec 1, 2015
1 parent ea14d1c commit d2dfc91
Show file tree
Hide file tree
Showing 77 changed files with 172 additions and 183 deletions.
4 changes: 2 additions & 2 deletions contrib/mesos/pkg/service/endpoints_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewEndpointController(client *client.Client) *endpointController {
return e.client.Services(api.NamespaceAll).List(labels.Everything(), fields.Everything())
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
return e.client.Services(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), options)
return e.client.Services(api.NamespaceAll).Watch(options)
},
},
&api.Service{},
Expand All @@ -83,7 +83,7 @@ func NewEndpointController(client *client.Client) *endpointController {
return e.client.Pods(api.NamespaceAll).List(labels.Everything(), fields.Everything())
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
return e.client.Pods(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), options)
return e.client.Pods(api.NamespaceAll).Watch(options)
},
},
&api.Pod{},
Expand Down
6 changes: 2 additions & 4 deletions pkg/client/unversioned/daemon_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type DaemonSetInterface interface {
Update(ctrl *extensions.DaemonSet) (*extensions.DaemonSet, error)
UpdateStatus(ctrl *extensions.DaemonSet) (*extensions.DaemonSet, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// daemonSets implements DaemonsSetsNamespacer interface
Expand Down Expand Up @@ -93,13 +93,11 @@ func (c *daemonSets) Delete(name string) error {
}

// Watch returns a watch.Interface that watches the requested daemon sets.
func (c *daemonSets) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *daemonSets) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("daemonsets").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type DeploymentInterface interface {
Create(*extensions.Deployment) (*extensions.Deployment, error)
Update(*extensions.Deployment) (*extensions.Deployment, error)
UpdateStatus(*extensions.Deployment) (*extensions.Deployment, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// deployments implements DeploymentInterface
Expand Down Expand Up @@ -102,13 +102,11 @@ func (c *deployments) UpdateStatus(deployment *extensions.Deployment) (result *e
}

// Watch returns a watch.Interface that watches the requested deployments.
func (c *deployments) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *deployments) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("deployments").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ func TestDeploymentWatch(t *testing.T) {
},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).Deployments(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).Deployments(api.NamespaceAll).Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type EndpointsInterface interface {
Get(name string) (*api.Endpoints, error)
Delete(name string) error
Update(endpoints *api.Endpoints) (*api.Endpoints, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// endpoints implements EndpointsInterface
Expand Down Expand Up @@ -85,14 +85,12 @@ func (c *endpoints) Delete(name string) error {
}

// Watch returns a watch.Interface that watches the requested endpoints for a service.
func (c *endpoints) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *endpoints) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("endpoints").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/client/unversioned/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type EventInterface interface {
Patch(event *api.Event, data []byte) (*api.Event, error)
List(label labels.Selector, field fields.Selector) (*api.EventList, error)
Get(name string) (*api.Event, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
// Search finds events about the specified object
Search(objOrRef runtime.Object) (*api.EventList, error)
Delete(name string) error
Expand Down Expand Up @@ -142,14 +142,12 @@ func (e *events) Get(name string) (*api.Event, error) {
}

// Watch starts watching for events matching the given selectors.
func (e *events) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (e *events) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return e.client.Get().
Prefix("watch").
NamespaceIfScoped(e.namespace, len(e.namespace) > 0).
Resource("events").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/client/unversioned/horizontalpodautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type HorizontalPodAutoscalerInterface interface {
Create(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error)
Update(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error)
UpdateStatus(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// horizontalPodAutoscalers implements HorizontalPodAutoscalersNamespacer interface
Expand Down Expand Up @@ -104,13 +104,11 @@ func (c *horizontalPodAutoscalers) UpdateStatus(horizontalPodAutoscaler *extensi
}

// Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers.
func (c *horizontalPodAutoscalers) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *horizontalPodAutoscalers) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("horizontalPodAutoscalers").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/horizontalpodautoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ func TestHorizontalPodAutoscalerWatch(t *testing.T) {
Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).Extensions().HorizontalPodAutoscalers(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).Extensions().HorizontalPodAutoscalers(api.NamespaceAll).Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type IngressInterface interface {
Create(ingress *extensions.Ingress) (*extensions.Ingress, error)
Update(ingress *extensions.Ingress) (*extensions.Ingress, error)
Delete(name string, options *api.DeleteOptions) error
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
UpdateStatus(ingress *extensions.Ingress) (*extensions.Ingress, error)
}

Expand Down Expand Up @@ -94,14 +94,12 @@ func (c *ingress) Delete(name string, options *api.DeleteOptions) (err error) {
}

// Watch returns a watch.Interface that watches the requested ingress.
func (c *ingress) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *ingress) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("ingresses").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/client/unversioned/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type JobInterface interface {
Create(job *extensions.Job) (*extensions.Job, error)
Update(job *extensions.Job) (*extensions.Job, error)
Delete(name string, options *api.DeleteOptions) error
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
UpdateStatus(job *extensions.Job) (*extensions.Job, error)
}

Expand Down Expand Up @@ -98,14 +98,12 @@ func (c *jobs) Delete(name string, options *api.DeleteOptions) (err error) {
}

// Watch returns a watch.Interface that watches the requested jobs.
func (c *jobs) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *jobs) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("jobs").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/client/unversioned/limit_ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type LimitRangeInterface interface {
Delete(name string) error
Create(limitRange *api.LimitRange) (*api.LimitRange, error)
Update(limitRange *api.LimitRange) (*api.LimitRange, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// limitRanges implements LimitRangesNamespacer interface
Expand Down Expand Up @@ -93,13 +93,11 @@ func (c *limitRanges) Update(limitRange *api.LimitRange) (result *api.LimitRange
}

// Watch returns a watch.Interface that watches the requested resource
func (c *limitRanges) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *limitRanges) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("limitRanges").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/limit_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,6 @@ func TestLimitRangeWatch(t *testing.T) {
Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).LimitRanges(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).LimitRanges(api.NamespaceAll).Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type NamespaceInterface interface {
List(label labels.Selector, field fields.Selector) (*api.NamespaceList, error)
Delete(name string) error
Update(item *api.Namespace) (*api.Namespace, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
Finalize(item *api.Namespace) (*api.Namespace, error)
Status(item *api.Namespace) (*api.Namespace, error)
}
Expand Down Expand Up @@ -115,12 +115,10 @@ func (c *namespaces) Delete(name string) error {
}

// Watch returns a watch.Interface that watches the requested namespaces.
func (c *namespaces) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *namespaces) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Resource("namespaces").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ func TestNamespaceWatch(t *testing.T) {
Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).Namespaces().Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).Namespaces().Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type NodeInterface interface {
Delete(name string) error
Update(*api.Node) (*api.Node, error)
UpdateStatus(*api.Node) (*api.Node, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// nodes implements NodesInterface
Expand Down Expand Up @@ -103,13 +103,11 @@ func (c *nodes) UpdateStatus(node *api.Node) (*api.Node, error) {
}

// Watch returns a watch.Interface that watches the requested nodes.
func (c *nodes) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *nodes) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(api.NamespaceAll).
Resource(c.resourceName()).
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/persistentvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ func TestPersistentVolumeWatch(t *testing.T) {
Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).PersistentVolumes().Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).PersistentVolumes().Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/persistentvolumeclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type PersistentVolumeClaimInterface interface {
Update(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error)
UpdateStatus(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// persistentVolumeClaims implements PersistentVolumeClaimsNamespacer interface
Expand Down Expand Up @@ -99,13 +99,11 @@ func (c *persistentVolumeClaims) Delete(name string) error {
return c.client.Delete().Namespace(c.namespace).Resource("persistentVolumeClaims").Name(name).Do().Error()
}

func (c *persistentVolumeClaims) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *persistentVolumeClaims) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.namespace).
Resource("persistentVolumeClaims").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/persistentvolumeclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ func TestPersistentVolumeClaimWatch(t *testing.T) {
Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).PersistentVolumeClaims(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).PersistentVolumeClaims(api.NamespaceAll).Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/persistentvolumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type PersistentVolumeInterface interface {
Update(volume *api.PersistentVolume) (*api.PersistentVolume, error)
UpdateStatus(persistentVolume *api.PersistentVolume) (*api.PersistentVolume, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// persistentVolumes implements PersistentVolumesInterface
Expand Down Expand Up @@ -94,12 +94,10 @@ func (c *persistentVolumes) Delete(name string) error {
return c.client.Delete().Resource("persistentVolumes").Name(name).Do().Error()
}

func (c *persistentVolumes) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *persistentVolumes) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Resource("persistentVolumes").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
6 changes: 2 additions & 4 deletions pkg/client/unversioned/pod_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type PodTemplateInterface interface {
Delete(name string, options *api.DeleteOptions) error
Create(podTemplate *api.PodTemplate) (*api.PodTemplate, error)
Update(podTemplate *api.PodTemplate) (*api.PodTemplate, error)
Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error)
Watch(opts unversioned.ListOptions) (watch.Interface, error)
}

// podTemplates implements PodTemplatesNamespacer interface
Expand Down Expand Up @@ -95,13 +95,11 @@ func (c *podTemplates) Update(podTemplate *api.PodTemplate) (result *api.PodTemp
}

// Watch returns a watch.Interface that watches the requested podTemplates.
func (c *podTemplates) Watch(label labels.Selector, field fields.Selector, opts unversioned.ListOptions) (watch.Interface, error) {
func (c *podTemplates) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("podTemplates").
VersionedParams(&opts, api.Scheme).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
2 changes: 1 addition & 1 deletion pkg/client/unversioned/pod_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ func TestPodTemplateWatch(t *testing.T) {
Query: url.Values{"resourceVersion": []string{}}},
Response: Response{StatusCode: 200},
}
_, err := c.Setup(t).PodTemplates(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), unversioned.ListOptions{})
_, err := c.Setup(t).PodTemplates(api.NamespaceAll).Watch(unversioned.ListOptions{})
c.Validate(t, nil, err)
}
Loading

0 comments on commit d2dfc91

Please sign in to comment.