From a4b00e33e076988fea9bf73fa75367c4edca50cc Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Wed, 27 Aug 2014 18:57:29 +0000 Subject: [PATCH 1/2] Adding ListMinions() API to pkg/client. --- pkg/client/client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/client/client.go b/pkg/client/client.go index d624442910a..5128e3693e8 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -40,6 +40,7 @@ type Interface interface { ReplicationControllerInterface ServiceInterface VersionInterface + MinionInterface } // PodInterface has methods to work with Pod resources @@ -74,6 +75,10 @@ type VersionInterface interface { ServerVersion() (*version.Info, error) } +type MinionInterface interface { + ListMinions() (api.MinionList, error) +} + // Client is the actual implementation of a Kubernetes client. type Client struct { *RESTClient @@ -322,3 +327,8 @@ func (c *Client) ServerVersion() (*version.Info, error) { } return &info, nil } + +func (c *Client) ListMinions() (minionList api.MinionList, err error) { + err = c.Get().Path("minions").Do().Into(&minionList) + return +} From 180e9ed493c50cf536654c2b5b278d3cca756631 Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Wed, 27 Aug 2014 21:07:22 +0000 Subject: [PATCH 2/2] Add unit tests for pkg/client.ListMinions() --- pkg/client/client.go | 1 + pkg/client/client_test.go | 9 +++++++++ pkg/client/fake.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/pkg/client/client.go b/pkg/client/client.go index 5128e3693e8..eb1902dee56 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -328,6 +328,7 @@ func (c *Client) ServerVersion() (*version.Info, error) { return &info, nil } +// Lists all the minions in the cluster. func (c *Client) ListMinions() (minionList api.MinionList, err error) { err = c.Get().Path("minions").Do().Into(&minionList) return diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 21c2d440d20..74166adc6de 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -515,3 +515,12 @@ func TestGetServerVersion(t *testing.T) { t.Errorf("expected %v, got %v", e, a) } } + +func TestListMinions(t *testing.T) { + c := &testClient{ + Request: testRequest{Method: "GET", Path: "/minions"}, + Response: Response{StatusCode: 200, Body: &api.MinionList{JSONBase: api.JSONBase{ID: "minion-1"}}}, + } + response, err := c.Setup().ListMinions() + c.Validate(t, &response, err) +} diff --git a/pkg/client/fake.go b/pkg/client/fake.go index b03f599a1c7..d8e7d14a5b2 100644 --- a/pkg/client/fake.go +++ b/pkg/client/fake.go @@ -117,3 +117,8 @@ func (c *Fake) ServerVersion() (*version.Info, error) { versionInfo := version.Get() return &versionInfo, nil } + +func (c *Fake) ListMinions() (api.MinionList, error) { + c.Actions = append(c.Actions, FakeAction{Action: "list-minions", Value: nil}) + return api.MinionList{}, nil +}