Merge pull request #13425 from jszczepkowski/hpa-kind

Fixed kind to resource convertion in scale client.
This commit is contained in:
Piotr Szczesniak 2015-09-04 09:04:00 +02:00
commit 14f4d3ad0e

View File

@ -17,9 +17,7 @@ limitations under the License.
package unversioned package unversioned
import ( import (
"fmt" "k8s.io/kubernetes/pkg/api/meta"
"strings"
"k8s.io/kubernetes/pkg/expapi" "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. // 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) { func (c *scales) Get(kind string, name string) (result *expapi.Scale, err error) {
result = &expapi.Scale{} result = &expapi.Scale{}
if strings.ToLower(kind) == "replicationcontroller" { resource, _ := meta.KindToResource(kind, false)
kind = "replicationControllers" err = c.client.Get().Namespace(c.ns).Resource(resource).Name(name).SubResource("scale").Do().Into(result)
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)
return return
} }
func (c *scales) Update(kind string, scale *expapi.Scale) (result *expapi.Scale, err error) { func (c *scales) Update(kind string, scale *expapi.Scale) (result *expapi.Scale, err error) {
result = &expapi.Scale{} result = &expapi.Scale{}
if strings.ToLower(kind) == "replicationcontroller" { resource, _ := meta.KindToResource(kind, false)
kind = "replicationControllers" err = c.client.Put().
Namespace(scale.Namespace).
err = c.client.Put(). Resource(resource).
Namespace(scale.Namespace). Name(scale.Name).
Resource(kind). SubResource("scale").
Name(scale.Name). Body(scale).
SubResource("scale"). Do().
Body(scale). Into(result)
Do().
Into(result)
return
}
err = fmt.Errorf("Kind not supported: %s", kind)
return return
} }