mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-09 08:55:55 -04:00
Merge pull request #719 from csrwng/list_replication_controllers
Add a method to list replication controllers
This commit is contained in:
commit
28d42a79a4
3 changed files with 37 additions and 0 deletions
|
|
@ -40,6 +40,7 @@ type Interface interface {
|
|||
CreatePod(api.Pod) (api.Pod, error)
|
||||
UpdatePod(api.Pod) (api.Pod, error)
|
||||
|
||||
ListReplicationControllers(selector labels.Selector) (api.ReplicationControllerList, error)
|
||||
GetReplicationController(name string) (api.ReplicationController, error)
|
||||
CreateReplicationController(api.ReplicationController) (api.ReplicationController, error)
|
||||
UpdateReplicationController(api.ReplicationController) (api.ReplicationController, error)
|
||||
|
|
@ -195,6 +196,12 @@ func (c *Client) UpdatePod(pod api.Pod) (result api.Pod, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// ListReplicationControllers takes a selector, and returns the list of replication controllers that match that selector
|
||||
func (c *Client) ListReplicationControllers(selector labels.Selector) (result api.ReplicationControllerList, err error) {
|
||||
err = c.Get().Path("replicationControllers").Selector(selector).Do().Into(&result)
|
||||
return
|
||||
}
|
||||
|
||||
// GetReplicationController returns information about a particular replication controller
|
||||
func (c *Client) GetReplicationController(name string) (result api.ReplicationController, err error) {
|
||||
err = c.Get().Path("replicationControllers").Path(name).Do().Into(&result)
|
||||
|
|
|
|||
|
|
@ -171,6 +171,31 @@ func TestUpdatePod(t *testing.T) {
|
|||
c.Validate(t, receivedPod, err)
|
||||
}
|
||||
|
||||
func TestListControllers(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: "/replicationControllers"},
|
||||
Response: Response{StatusCode: 200,
|
||||
Body: api.ReplicationControllerList{
|
||||
Items: []api.ReplicationController{
|
||||
{
|
||||
JSONBase: api.JSONBase{ID: "foo"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedControllerList, err := c.Setup().ListReplicationControllers(nil)
|
||||
c.Validate(t, receivedControllerList, err)
|
||||
|
||||
}
|
||||
|
||||
func TestGetController(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: "/replicationControllers/foo"},
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ func (client *FakeKubeClient) UpdatePod(pod api.Pod) (api.Pod, error) {
|
|||
return api.Pod{}, nil
|
||||
}
|
||||
|
||||
func (client *FakeKubeClient) ListReplicationControllers(selector labels.Selector) (api.ReplicationControllerList, error) {
|
||||
client.actions = append(client.actions, Action{action: "list-controllers"})
|
||||
return api.ReplicationControllerList{}, nil
|
||||
}
|
||||
|
||||
func (client *FakeKubeClient) GetReplicationController(name string) (api.ReplicationController, error) {
|
||||
client.actions = append(client.actions, Action{action: "get-controller", value: name})
|
||||
return client.ctrl, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue