From 64101cbe6af269eb4cc4654e49fc3c6af0502d0c Mon Sep 17 00:00:00 2001 From: Josh Horwitz Date: Mon, 26 Feb 2018 14:03:11 -0500 Subject: [PATCH] Fixes fake client generation for non-namespaced subresources Kubernetes-commit: 0f62a8cddac0a48506fc1b93f37da32530fd2358 --- testing/actions.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/testing/actions.go b/testing/actions.go index 0210b678..232cf21e 100644 --- a/testing/actions.go +++ b/testing/actions.go @@ -58,6 +58,16 @@ func NewGetSubresourceAction(resource schema.GroupVersionResource, namespace, su return action } +func NewRootGetSubresourceAction(resource schema.GroupVersionResource, subresource, name string) GetActionImpl { + action := GetActionImpl{} + action.Verb = "get" + action.Resource = resource + action.Subresource = subresource + action.Name = name + + return action +} + func NewRootListAction(resource schema.GroupVersionResource, kind schema.GroupVersionKind, opts interface{}) ListActionImpl { action := ListActionImpl{} action.Verb = "list" @@ -81,20 +91,6 @@ func NewListAction(resource schema.GroupVersionResource, kind schema.GroupVersio return action } -func NewListSubresourceAction(resource schema.GroupVersionResource, name, subresource string, kind schema.GroupVersionKind, namespace string, opts interface{}) ListActionImpl { - action := ListActionImpl{} - action.Verb = "list" - action.Resource = resource - action.Subresource = subresource - action.Kind = kind - action.Namespace = namespace - action.Name = name - labelSelector, fieldSelector, _ := ExtractFromListOptions(opts) - action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} - - return action -} - func NewRootCreateAction(resource schema.GroupVersionResource, object runtime.Object) CreateActionImpl { action := CreateActionImpl{} action.Verb = "create" @@ -114,12 +110,23 @@ func NewCreateAction(resource schema.GroupVersionResource, namespace string, obj return action } -func NewCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource string, namespace string, object runtime.Object) CreateActionImpl { +func NewRootCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource string, object runtime.Object) CreateActionImpl { action := CreateActionImpl{} action.Verb = "create" action.Resource = resource action.Subresource = subresource + action.Name = name + action.Object = object + + return action +} + +func NewCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource, namespace string, object runtime.Object) CreateActionImpl { + action := CreateActionImpl{} + action.Verb = "create" + action.Resource = resource action.Namespace = namespace + action.Subresource = subresource action.Name = name action.Object = object