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
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
}