use fully qualified resource in fake clients actions

This commit is contained in:
Chao Xu
2016-04-13 15:33:15 -07:00
parent f8d4f6157f
commit 8537095415
172 changed files with 1494 additions and 1175 deletions

View File

@@ -20,12 +20,13 @@ import (
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
)
func NewRootGetAction(resource, name string) GetActionImpl {
func NewRootGetAction(resource unversioned.GroupVersionResource, name string) GetActionImpl {
action := GetActionImpl{}
action.Verb = "get"
action.Resource = resource
@@ -34,7 +35,7 @@ func NewRootGetAction(resource, name string) GetActionImpl {
return action
}
func NewGetAction(resource, namespace, name string) GetActionImpl {
func NewGetAction(resource unversioned.GroupVersionResource, namespace, name string) GetActionImpl {
action := GetActionImpl{}
action.Verb = "get"
action.Resource = resource
@@ -44,7 +45,7 @@ func NewGetAction(resource, namespace, name string) GetActionImpl {
return action
}
func NewRootListAction(resource string, opts api.ListOptions) ListActionImpl {
func NewRootListAction(resource unversioned.GroupVersionResource, opts api.ListOptions) ListActionImpl {
action := ListActionImpl{}
action.Verb = "list"
action.Resource = resource
@@ -61,7 +62,7 @@ func NewRootListAction(resource string, opts api.ListOptions) ListActionImpl {
return action
}
func NewListAction(resource, namespace string, opts api.ListOptions) ListActionImpl {
func NewListAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) ListActionImpl {
action := ListActionImpl{}
action.Verb = "list"
action.Resource = resource
@@ -79,7 +80,7 @@ func NewListAction(resource, namespace string, opts api.ListOptions) ListActionI
return action
}
func NewRootCreateAction(resource string, object runtime.Object) CreateActionImpl {
func NewRootCreateAction(resource unversioned.GroupVersionResource, object runtime.Object) CreateActionImpl {
action := CreateActionImpl{}
action.Verb = "create"
action.Resource = resource
@@ -88,7 +89,7 @@ func NewRootCreateAction(resource string, object runtime.Object) CreateActionImp
return action
}
func NewCreateAction(resource, namespace string, object runtime.Object) CreateActionImpl {
func NewCreateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) CreateActionImpl {
action := CreateActionImpl{}
action.Verb = "create"
action.Resource = resource
@@ -98,7 +99,7 @@ func NewCreateAction(resource, namespace string, object runtime.Object) CreateAc
return action
}
func NewRootUpdateAction(resource string, object runtime.Object) UpdateActionImpl {
func NewRootUpdateAction(resource unversioned.GroupVersionResource, object runtime.Object) UpdateActionImpl {
action := UpdateActionImpl{}
action.Verb = "update"
action.Resource = resource
@@ -107,7 +108,7 @@ func NewRootUpdateAction(resource string, object runtime.Object) UpdateActionImp
return action
}
func NewUpdateAction(resource, namespace string, object runtime.Object) UpdateActionImpl {
func NewUpdateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) UpdateActionImpl {
action := UpdateActionImpl{}
action.Verb = "update"
action.Resource = resource
@@ -117,7 +118,7 @@ func NewUpdateAction(resource, namespace string, object runtime.Object) UpdateAc
return action
}
func NewRootPatchAction(resource string, object runtime.Object) PatchActionImpl {
func NewRootPatchAction(resource unversioned.GroupVersionResource, object runtime.Object) PatchActionImpl {
action := PatchActionImpl{}
action.Verb = "patch"
action.Resource = resource
@@ -126,7 +127,7 @@ func NewRootPatchAction(resource string, object runtime.Object) PatchActionImpl
return action
}
func NewPatchAction(resource, namespace string, object runtime.Object) PatchActionImpl {
func NewPatchAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) PatchActionImpl {
action := PatchActionImpl{}
action.Verb = "patch"
action.Resource = resource
@@ -136,7 +137,7 @@ func NewPatchAction(resource, namespace string, object runtime.Object) PatchActi
return action
}
func NewRootUpdateSubresourceAction(resource, subresource string, object runtime.Object) UpdateActionImpl {
func NewRootUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, object runtime.Object) UpdateActionImpl {
action := UpdateActionImpl{}
action.Verb = "update"
action.Resource = resource
@@ -145,7 +146,7 @@ func NewRootUpdateSubresourceAction(resource, subresource string, object runtime
return action
}
func NewUpdateSubresourceAction(resource, subresource, namespace string, object runtime.Object) UpdateActionImpl {
func NewUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, namespace string, object runtime.Object) UpdateActionImpl {
action := UpdateActionImpl{}
action.Verb = "update"
action.Resource = resource
@@ -156,7 +157,7 @@ func NewUpdateSubresourceAction(resource, subresource, namespace string, object
return action
}
func NewRootDeleteAction(resource, name string) DeleteActionImpl {
func NewRootDeleteAction(resource unversioned.GroupVersionResource, name string) DeleteActionImpl {
action := DeleteActionImpl{}
action.Verb = "delete"
action.Resource = resource
@@ -165,7 +166,7 @@ func NewRootDeleteAction(resource, name string) DeleteActionImpl {
return action
}
func NewDeleteAction(resource, namespace, name string) DeleteActionImpl {
func NewDeleteAction(resource unversioned.GroupVersionResource, namespace, name string) DeleteActionImpl {
action := DeleteActionImpl{}
action.Verb = "delete"
action.Resource = resource
@@ -175,7 +176,7 @@ func NewDeleteAction(resource, namespace, name string) DeleteActionImpl {
return action
}
func NewRootDeleteCollectionAction(resource string, opts api.ListOptions) DeleteCollectionActionImpl {
func NewRootDeleteCollectionAction(resource unversioned.GroupVersionResource, opts api.ListOptions) DeleteCollectionActionImpl {
action := DeleteCollectionActionImpl{}
action.Verb = "delete-collection"
action.Resource = resource
@@ -192,7 +193,7 @@ func NewRootDeleteCollectionAction(resource string, opts api.ListOptions) Delete
return action
}
func NewDeleteCollectionAction(resource, namespace string, opts api.ListOptions) DeleteCollectionActionImpl {
func NewDeleteCollectionAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) DeleteCollectionActionImpl {
action := DeleteCollectionActionImpl{}
action.Verb = "delete-collection"
action.Resource = resource
@@ -210,7 +211,7 @@ func NewDeleteCollectionAction(resource, namespace string, opts api.ListOptions)
return action
}
func NewRootWatchAction(resource string, opts api.ListOptions) WatchActionImpl {
func NewRootWatchAction(resource unversioned.GroupVersionResource, opts api.ListOptions) WatchActionImpl {
action := WatchActionImpl{}
action.Verb = "watch"
action.Resource = resource
@@ -227,7 +228,7 @@ func NewRootWatchAction(resource string, opts api.ListOptions) WatchActionImpl {
return action
}
func NewWatchAction(resource, namespace string, opts api.ListOptions) WatchActionImpl {
func NewWatchAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) WatchActionImpl {
action := WatchActionImpl{}
action.Verb = "watch"
action.Resource = resource
@@ -245,7 +246,7 @@ func NewWatchAction(resource, namespace string, opts api.ListOptions) WatchActio
return action
}
func NewProxyGetAction(resource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl {
func NewProxyGetAction(resource unversioned.GroupVersionResource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl {
action := ProxyGetActionImpl{}
action.Verb = "get"
action.Resource = resource
@@ -271,7 +272,7 @@ type WatchRestrictions struct {
type Action interface {
GetNamespace() string
GetVerb() string
GetResource() string
GetResource() unversioned.GroupVersionResource
GetSubresource() string
Matches(verb, resource string) bool
}
@@ -323,7 +324,7 @@ type ProxyGetAction interface {
type ActionImpl struct {
Namespace string
Verb string
Resource string
Resource unversioned.GroupVersionResource
Subresource string
}
@@ -333,7 +334,7 @@ func (a ActionImpl) GetNamespace() string {
func (a ActionImpl) GetVerb() string {
return a.Verb
}
func (a ActionImpl) GetResource() string {
func (a ActionImpl) GetResource() unversioned.GroupVersionResource {
return a.Resource
}
func (a ActionImpl) GetSubresource() string {
@@ -341,7 +342,7 @@ func (a ActionImpl) GetSubresource() string {
}
func (a ActionImpl) Matches(verb, resource string) bool {
return strings.ToLower(verb) == strings.ToLower(a.Verb) &&
strings.ToLower(resource) == strings.ToLower(a.Resource)
strings.ToLower(resource) == strings.ToLower(a.Resource.Resource)
}
type GenericActionImpl struct {