From a2ca4954f48b2588d28e5e8c2d24ed6e4cb76123 Mon Sep 17 00:00:00 2001 From: Jerzy Szczepkowski Date: Tue, 1 Sep 2015 08:07:39 +0200 Subject: [PATCH] Fixed kind to resource convertion in scale client. Fixed kind to resource convertion in scale client. --- pkg/client/unversioned/scale.go | 35 +++++++++++---------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/pkg/client/unversioned/scale.go b/pkg/client/unversioned/scale.go index c0d4b662e37..4152ec9b2fb 100644 --- a/pkg/client/unversioned/scale.go +++ b/pkg/client/unversioned/scale.go @@ -17,9 +17,7 @@ limitations under the License. package unversioned import ( - "fmt" - "strings" - + "k8s.io/kubernetes/pkg/api/meta" "k8s.io/kubernetes/pkg/expapi" ) @@ -50,30 +48,21 @@ func newScales(c *ExperimentalClient, namespace string) *scales { // Get takes the reference to scale subresource and returns the subresource or error, if one occurs. func (c *scales) Get(kind string, name string) (result *expapi.Scale, err error) { result = &expapi.Scale{} - if strings.ToLower(kind) == "replicationcontroller" { - kind = "replicationControllers" - err = c.client.Get().Namespace(c.ns).Resource(kind).Name(name).SubResource("scale").Do().Into(result) - return - } - err = fmt.Errorf("Kind not supported: %s", kind) + resource, _ := meta.KindToResource(kind, false) + err = c.client.Get().Namespace(c.ns).Resource(resource).Name(name).SubResource("scale").Do().Into(result) return } func (c *scales) Update(kind string, scale *expapi.Scale) (result *expapi.Scale, err error) { result = &expapi.Scale{} - if strings.ToLower(kind) == "replicationcontroller" { - kind = "replicationControllers" - - err = c.client.Put(). - Namespace(scale.Namespace). - Resource(kind). - Name(scale.Name). - SubResource("scale"). - Body(scale). - Do(). - Into(result) - return - } - err = fmt.Errorf("Kind not supported: %s", kind) + resource, _ := meta.KindToResource(kind, false) + err = c.client.Put(). + Namespace(scale.Namespace). + Resource(resource). + Name(scale.Name). + SubResource("scale"). + Body(scale). + Do(). + Into(result) return }