Merge pull request #5235 from jszczepkowski/pods-watch
Watch support in PodInterface.
This commit is contained in:
@@ -19,6 +19,7 @@ package client
|
||||
import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
// FakePods implements PodsInterface. Meant to be embedded into a struct to get a default
|
||||
@@ -53,6 +54,11 @@ func (c *FakePods) Update(pod *api.Pod) (*api.Pod, error) {
|
||||
return &api.Pod{}, nil
|
||||
}
|
||||
|
||||
func (c *FakePods) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
|
||||
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-pods", Value: resourceVersion})
|
||||
return c.Fake.Watch, c.Fake.Err
|
||||
}
|
||||
|
||||
func (c *FakePods) Bind(bind *api.Binding) error {
|
||||
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "bind-pod", Value: bind.Name})
|
||||
return nil
|
||||
|
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
// PodsNamespacer has methods to work with Pod resources in a namespace
|
||||
@@ -36,7 +37,7 @@ type PodInterface interface {
|
||||
Delete(name string) error
|
||||
Create(pod *api.Pod) (*api.Pod, error)
|
||||
Update(pod *api.Pod) (*api.Pod, error)
|
||||
|
||||
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
|
||||
Bind(binding *api.Binding) error
|
||||
}
|
||||
|
||||
@@ -95,6 +96,18 @@ func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested pods.
|
||||
func (c *pods) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
|
||||
return c.r.Get().
|
||||
Prefix("watch").
|
||||
Namespace(c.ns).
|
||||
Resource("pods").
|
||||
Param("resourceVersion", resourceVersion).
|
||||
SelectorParam("labels", label).
|
||||
SelectorParam("fields", field).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||
func (c *pods) Bind(binding *api.Binding) error {
|
||||
return c.r.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error()
|
||||
|
Reference in New Issue
Block a user