From 5c0e283ed80272ca1e17a046d572f3cc1048f221 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Fri, 23 Aug 2019 10:50:45 +0100 Subject: [PATCH] update scale client to support non-namespaced resources Kubernetes-commit: fcd44b44cadef56e9782dcc875f5572cbc43b018 --- scale/client.go | 6 +++--- scale/interfaces.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scale/client.go b/scale/client.go index 7084c1a4..17519345 100644 --- a/scale/client.go +++ b/scale/client.go @@ -150,7 +150,7 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string) result := c.client.clientBase.Get(). AbsPath(path). - Namespace(c.namespace). + NamespaceIfScoped(c.namespace, c.namespace != ""). Resource(gvr.Resource). Name(name). SubResource("scale"). @@ -191,7 +191,7 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut result := c.client.clientBase.Put(). AbsPath(path). - Namespace(c.namespace). + NamespaceIfScoped(c.namespace, c.namespace != ""). Resource(gvr.Resource). Name(scale.Name). SubResource("scale"). @@ -211,7 +211,7 @@ func (c *namespacedScaleClient) Patch(gvr schema.GroupVersionResource, name stri groupVersion := gvr.GroupVersion() result := c.client.clientBase.Patch(pt). AbsPath(c.client.apiPathFor(groupVersion)). - Namespace(c.namespace). + NamespaceIfScoped(c.namespace, c.namespace != ""). Resource(gvr.Resource). Name(name). SubResource("scale"). diff --git a/scale/interfaces.go b/scale/interfaces.go index 48d0da6f..16c20d79 100644 --- a/scale/interfaces.go +++ b/scale/interfaces.go @@ -23,8 +23,9 @@ import ( ) // ScalesGetter can produce a ScaleInterface -// for a particular namespace. type ScalesGetter interface { + // Scales produces a ScaleInterface for a particular namespace. + // Set namespace to the empty string for non-namespaced resources. Scales(namespace string) ScaleInterface }