From bf85a9d89b2bc076feb82757bda5e4d086ade764 Mon Sep 17 00:00:00 2001 From: Michal Fojtik Date: Wed, 30 Aug 2017 18:09:52 +0200 Subject: [PATCH] add missing sub-resources test actions Kubernetes-commit: c026b62d19d83d4f68235d1bd039a469e87d215d --- testing/actions.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/testing/actions.go b/testing/actions.go index 8633a81d..6f1c3a89 100644 --- a/testing/actions.go +++ b/testing/actions.go @@ -47,6 +47,17 @@ func NewGetAction(resource schema.GroupVersionResource, namespace, name string) return action } +func NewGetSubresourceAction(resource schema.GroupVersionResource, namespace, subresource, name string) GetActionImpl { + action := GetActionImpl{} + action.Verb = "get" + action.Resource = resource + action.Subresource = subresource + action.Namespace = namespace + action.Name = name + + return action +} + func NewRootListAction(resource schema.GroupVersionResource, kind schema.GroupVersionKind, opts interface{}) ListActionImpl { action := ListActionImpl{} action.Verb = "list" @@ -70,6 +81,20 @@ 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" @@ -89,6 +114,18 @@ func NewCreateAction(resource schema.GroupVersionResource, namespace string, obj return action } +func NewCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource string, namespace string, object runtime.Object) CreateActionImpl { + action := CreateActionImpl{} + action.Verb = "create" + action.Resource = resource + action.Subresource = subresource + action.Namespace = namespace + action.Name = name + action.Object = object + + return action +} + func NewRootUpdateAction(resource schema.GroupVersionResource, object runtime.Object) UpdateActionImpl { action := UpdateActionImpl{} action.Verb = "update" @@ -389,6 +426,7 @@ func (a GetActionImpl) GetName() string { type ListActionImpl struct { ActionImpl Kind schema.GroupVersionKind + Name string ListRestrictions ListRestrictions } @@ -402,6 +440,7 @@ func (a ListActionImpl) GetListRestrictions() ListRestrictions { type CreateActionImpl struct { ActionImpl + Name string Object runtime.Object }