mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Add fake client to make testing easier.
This commit is contained in:
@@ -28,11 +28,14 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// Interface holds the methods for clients of Kubenetes,
|
||||
// an interface to allow mock testing.
|
||||
// TODO: split this up by resource?
|
||||
// TODO: these should return/take pointers.
|
||||
type Interface interface {
|
||||
ListPods(selector labels.Selector) (api.PodList, error)
|
||||
GetPod(name string) (api.Pod, error)
|
||||
@@ -45,6 +48,7 @@ type Interface interface {
|
||||
CreateReplicationController(api.ReplicationController) (api.ReplicationController, error)
|
||||
UpdateReplicationController(api.ReplicationController) (api.ReplicationController, error)
|
||||
DeleteReplicationController(string) error
|
||||
WatchReplicationControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
|
||||
|
||||
GetService(name string) (api.Service, error)
|
||||
CreateService(api.Service) (api.Service, error)
|
||||
@@ -233,6 +237,17 @@ func (c *Client) DeleteReplicationController(name string) error {
|
||||
return c.Delete().Path("replicationControllers").Path(name).Do().Error()
|
||||
}
|
||||
|
||||
// WatchReplicationControllers returns a watch.Interface that watches the requested controllers.
|
||||
func (c *Client) WatchReplicationControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
return c.Get().
|
||||
Path("watch").
|
||||
Path("replicationControllers").
|
||||
UintParam("resourceVersion", resourceVersion).
|
||||
SelectorParam("labels", label).
|
||||
SelectorParam("fields", field).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// GetService returns information about a particular service.
|
||||
func (c *Client) GetService(name string) (result api.Service, err error) {
|
||||
err = c.Get().Path("services").Path(name).Do().Into(&result)
|
||||
|
Reference in New Issue
Block a user