find partial resource matches

This commit is contained in:
deads2k
2015-12-07 08:12:24 -05:00
parent 3415f1dfc2
commit 41b78ad2b6
21 changed files with 699 additions and 135 deletions

View File

@@ -18,6 +18,7 @@ package unversioned
import (
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
)
@@ -48,17 +49,25 @@ func newScales(c *ExtensionsClient, 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 *extensions.Scale, err error) {
result = &extensions.Scale{}
resource, _ := meta.KindToResource(kind, false)
err = c.client.Get().Namespace(c.ns).Resource(resource).Name(name).SubResource("scale").Do().Into(result)
// TODO this method needs to take a proper unambiguous kind
fullyQualifiedKind := unversioned.GroupVersionKind{Kind: kind}
resource, _ := meta.KindToResource(fullyQualifiedKind, false)
err = c.client.Get().Namespace(c.ns).Resource(resource.Resource).Name(name).SubResource("scale").Do().Into(result)
return
}
func (c *scales) Update(kind string, scale *extensions.Scale) (result *extensions.Scale, err error) {
result = &extensions.Scale{}
resource, _ := meta.KindToResource(kind, false)
// TODO this method needs to take a proper unambiguous kind
fullyQualifiedKind := unversioned.GroupVersionKind{Kind: kind}
resource, _ := meta.KindToResource(fullyQualifiedKind, false)
err = c.client.Put().
Namespace(scale.Namespace).
Resource(resource).
Resource(resource.Resource).
Name(scale.Name).
SubResource("scale").
Body(scale).