mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-06 01:20:40 +00:00
published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub) copied from https://github.com/kubernetes/kubernetes.git, branch master, last commit is 124fb610dcbd445fa710da67508ac6d5b822f61d
This commit is contained in:
@@ -22,14 +22,14 @@ import (
|
||||
"strings"
|
||||
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/fields"
|
||||
"k8s.io/client-go/pkg/labels"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func NewRootGetAction(resource unversioned.GroupVersionResource, name string) GetActionImpl {
|
||||
func NewRootGetAction(resource schema.GroupVersionResource, name string) GetActionImpl {
|
||||
action := GetActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = resource
|
||||
@@ -38,7 +38,7 @@ func NewRootGetAction(resource unversioned.GroupVersionResource, name string) Ge
|
||||
return action
|
||||
}
|
||||
|
||||
func NewGetAction(resource unversioned.GroupVersionResource, namespace, name string) GetActionImpl {
|
||||
func NewGetAction(resource schema.GroupVersionResource, namespace, name string) GetActionImpl {
|
||||
action := GetActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = resource
|
||||
@@ -48,7 +48,7 @@ func NewGetAction(resource unversioned.GroupVersionResource, namespace, name str
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootListAction(resource unversioned.GroupVersionResource, opts interface{}) ListActionImpl {
|
||||
func NewRootListAction(resource schema.GroupVersionResource, opts interface{}) ListActionImpl {
|
||||
action := ListActionImpl{}
|
||||
action.Verb = "list"
|
||||
action.Resource = resource
|
||||
@@ -58,7 +58,7 @@ func NewRootListAction(resource unversioned.GroupVersionResource, opts interface
|
||||
return action
|
||||
}
|
||||
|
||||
func NewListAction(resource unversioned.GroupVersionResource, namespace string, opts interface{}) ListActionImpl {
|
||||
func NewListAction(resource schema.GroupVersionResource, namespace string, opts interface{}) ListActionImpl {
|
||||
action := ListActionImpl{}
|
||||
action.Verb = "list"
|
||||
action.Resource = resource
|
||||
@@ -69,7 +69,7 @@ func NewListAction(resource unversioned.GroupVersionResource, namespace string,
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootCreateAction(resource unversioned.GroupVersionResource, object runtime.Object) CreateActionImpl {
|
||||
func NewRootCreateAction(resource schema.GroupVersionResource, object runtime.Object) CreateActionImpl {
|
||||
action := CreateActionImpl{}
|
||||
action.Verb = "create"
|
||||
action.Resource = resource
|
||||
@@ -78,7 +78,7 @@ func NewRootCreateAction(resource unversioned.GroupVersionResource, object runti
|
||||
return action
|
||||
}
|
||||
|
||||
func NewCreateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) CreateActionImpl {
|
||||
func NewCreateAction(resource schema.GroupVersionResource, namespace string, object runtime.Object) CreateActionImpl {
|
||||
action := CreateActionImpl{}
|
||||
action.Verb = "create"
|
||||
action.Resource = resource
|
||||
@@ -88,7 +88,7 @@ func NewCreateAction(resource unversioned.GroupVersionResource, namespace string
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootUpdateAction(resource unversioned.GroupVersionResource, object runtime.Object) UpdateActionImpl {
|
||||
func NewRootUpdateAction(resource schema.GroupVersionResource, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
@@ -97,7 +97,7 @@ func NewRootUpdateAction(resource unversioned.GroupVersionResource, object runti
|
||||
return action
|
||||
}
|
||||
|
||||
func NewUpdateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) UpdateActionImpl {
|
||||
func NewUpdateAction(resource schema.GroupVersionResource, namespace string, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
@@ -107,7 +107,7 @@ func NewUpdateAction(resource unversioned.GroupVersionResource, namespace string
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootPatchAction(resource unversioned.GroupVersionResource, name string, patch []byte) PatchActionImpl {
|
||||
func NewRootPatchAction(resource schema.GroupVersionResource, name string, patch []byte) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
@@ -117,7 +117,7 @@ func NewRootPatchAction(resource unversioned.GroupVersionResource, name string,
|
||||
return action
|
||||
}
|
||||
|
||||
func NewPatchAction(resource unversioned.GroupVersionResource, namespace string, name string, patch []byte) PatchActionImpl {
|
||||
func NewPatchAction(resource schema.GroupVersionResource, namespace string, name string, patch []byte) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
@@ -128,7 +128,7 @@ func NewPatchAction(resource unversioned.GroupVersionResource, namespace string,
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootPatchSubresourceAction(resource unversioned.GroupVersionResource, name string, patch []byte, subresources ...string) PatchActionImpl {
|
||||
func NewRootPatchSubresourceAction(resource schema.GroupVersionResource, name string, patch []byte, subresources ...string) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
@@ -139,7 +139,7 @@ func NewRootPatchSubresourceAction(resource unversioned.GroupVersionResource, na
|
||||
return action
|
||||
}
|
||||
|
||||
func NewPatchSubresourceAction(resource unversioned.GroupVersionResource, namespace, name string, patch []byte, subresources ...string) PatchActionImpl {
|
||||
func NewPatchSubresourceAction(resource schema.GroupVersionResource, namespace, name string, patch []byte, subresources ...string) PatchActionImpl {
|
||||
action := PatchActionImpl{}
|
||||
action.Verb = "patch"
|
||||
action.Resource = resource
|
||||
@@ -151,7 +151,7 @@ func NewPatchSubresourceAction(resource unversioned.GroupVersionResource, namesp
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, object runtime.Object) UpdateActionImpl {
|
||||
func NewRootUpdateSubresourceAction(resource schema.GroupVersionResource, subresource string, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
@@ -160,7 +160,7 @@ func NewRootUpdateSubresourceAction(resource unversioned.GroupVersionResource, s
|
||||
|
||||
return action
|
||||
}
|
||||
func NewUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, namespace string, object runtime.Object) UpdateActionImpl {
|
||||
func NewUpdateSubresourceAction(resource schema.GroupVersionResource, subresource string, namespace string, object runtime.Object) UpdateActionImpl {
|
||||
action := UpdateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = resource
|
||||
@@ -171,7 +171,7 @@ func NewUpdateSubresourceAction(resource unversioned.GroupVersionResource, subre
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootDeleteAction(resource unversioned.GroupVersionResource, name string) DeleteActionImpl {
|
||||
func NewRootDeleteAction(resource schema.GroupVersionResource, name string) DeleteActionImpl {
|
||||
action := DeleteActionImpl{}
|
||||
action.Verb = "delete"
|
||||
action.Resource = resource
|
||||
@@ -180,7 +180,7 @@ func NewRootDeleteAction(resource unversioned.GroupVersionResource, name string)
|
||||
return action
|
||||
}
|
||||
|
||||
func NewDeleteAction(resource unversioned.GroupVersionResource, namespace, name string) DeleteActionImpl {
|
||||
func NewDeleteAction(resource schema.GroupVersionResource, namespace, name string) DeleteActionImpl {
|
||||
action := DeleteActionImpl{}
|
||||
action.Verb = "delete"
|
||||
action.Resource = resource
|
||||
@@ -190,7 +190,7 @@ func NewDeleteAction(resource unversioned.GroupVersionResource, namespace, name
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootDeleteCollectionAction(resource unversioned.GroupVersionResource, opts interface{}) DeleteCollectionActionImpl {
|
||||
func NewRootDeleteCollectionAction(resource schema.GroupVersionResource, opts interface{}) DeleteCollectionActionImpl {
|
||||
action := DeleteCollectionActionImpl{}
|
||||
action.Verb = "delete-collection"
|
||||
action.Resource = resource
|
||||
@@ -200,7 +200,7 @@ func NewRootDeleteCollectionAction(resource unversioned.GroupVersionResource, op
|
||||
return action
|
||||
}
|
||||
|
||||
func NewDeleteCollectionAction(resource unversioned.GroupVersionResource, namespace string, opts interface{}) DeleteCollectionActionImpl {
|
||||
func NewDeleteCollectionAction(resource schema.GroupVersionResource, namespace string, opts interface{}) DeleteCollectionActionImpl {
|
||||
action := DeleteCollectionActionImpl{}
|
||||
action.Verb = "delete-collection"
|
||||
action.Resource = resource
|
||||
@@ -211,7 +211,7 @@ func NewDeleteCollectionAction(resource unversioned.GroupVersionResource, namesp
|
||||
return action
|
||||
}
|
||||
|
||||
func NewRootWatchAction(resource unversioned.GroupVersionResource, opts interface{}) WatchActionImpl {
|
||||
func NewRootWatchAction(resource schema.GroupVersionResource, opts interface{}) WatchActionImpl {
|
||||
action := WatchActionImpl{}
|
||||
action.Verb = "watch"
|
||||
action.Resource = resource
|
||||
@@ -250,7 +250,7 @@ func ExtractFromListOptions(opts interface{}) (labelSelector labels.Selector, fi
|
||||
return labelSelector, fieldSelector, resourceVersion
|
||||
}
|
||||
|
||||
func NewWatchAction(resource unversioned.GroupVersionResource, namespace string, opts interface{}) WatchActionImpl {
|
||||
func NewWatchAction(resource schema.GroupVersionResource, namespace string, opts interface{}) WatchActionImpl {
|
||||
action := WatchActionImpl{}
|
||||
action.Verb = "watch"
|
||||
action.Resource = resource
|
||||
@@ -261,7 +261,7 @@ func NewWatchAction(resource unversioned.GroupVersionResource, namespace string,
|
||||
return action
|
||||
}
|
||||
|
||||
func NewProxyGetAction(resource unversioned.GroupVersionResource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl {
|
||||
func NewProxyGetAction(resource schema.GroupVersionResource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl {
|
||||
action := ProxyGetActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = resource
|
||||
@@ -287,7 +287,7 @@ type WatchRestrictions struct {
|
||||
type Action interface {
|
||||
GetNamespace() string
|
||||
GetVerb() string
|
||||
GetResource() unversioned.GroupVersionResource
|
||||
GetResource() schema.GroupVersionResource
|
||||
GetSubresource() string
|
||||
Matches(verb, resource string) bool
|
||||
}
|
||||
@@ -339,7 +339,7 @@ type ProxyGetAction interface {
|
||||
type ActionImpl struct {
|
||||
Namespace string
|
||||
Verb string
|
||||
Resource unversioned.GroupVersionResource
|
||||
Resource schema.GroupVersionResource
|
||||
Subresource string
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ func (a ActionImpl) GetNamespace() string {
|
||||
func (a ActionImpl) GetVerb() string {
|
||||
return a.Verb
|
||||
}
|
||||
func (a ActionImpl) GetResource() unversioned.GroupVersionResource {
|
||||
func (a ActionImpl) GetResource() schema.GroupVersionResource {
|
||||
return a.Resource
|
||||
}
|
||||
func (a ActionImpl) GetSubresource() string {
|
||||
|
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/version"
|
||||
"k8s.io/client-go/pkg/watch"
|
||||
"k8s.io/client-go/rest"
|
||||
@@ -221,7 +222,7 @@ type FakeDiscovery struct {
|
||||
func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error) {
|
||||
action := ActionImpl{
|
||||
Verb: "get",
|
||||
Resource: unversioned.GroupVersionResource{Resource: "resource"},
|
||||
Resource: schema.GroupVersionResource{Resource: "resource"},
|
||||
}
|
||||
c.Invokes(action, nil)
|
||||
return c.Resources[groupVersion], nil
|
||||
@@ -230,7 +231,7 @@ func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*un
|
||||
func (c *FakeDiscovery) ServerResources() (map[string]*unversioned.APIResourceList, error) {
|
||||
action := ActionImpl{
|
||||
Verb: "get",
|
||||
Resource: unversioned.GroupVersionResource{Resource: "resource"},
|
||||
Resource: schema.GroupVersionResource{Resource: "resource"},
|
||||
}
|
||||
c.Invokes(action, nil)
|
||||
return c.Resources, nil
|
||||
@@ -243,7 +244,7 @@ func (c *FakeDiscovery) ServerGroups() (*unversioned.APIGroupList, error) {
|
||||
func (c *FakeDiscovery) ServerVersion() (*version.Info, error) {
|
||||
action := ActionImpl{}
|
||||
action.Verb = "get"
|
||||
action.Resource = unversioned.GroupVersionResource{Resource: "version"}
|
||||
action.Resource = schema.GroupVersionResource{Resource: "version"}
|
||||
|
||||
c.Invokes(action, nil)
|
||||
versionInfo := version.Get()
|
||||
|
@@ -25,6 +25,7 @@ import (
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/apimachinery/registered"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/watch"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -38,19 +39,19 @@ type ObjectTracker interface {
|
||||
Add(obj runtime.Object) error
|
||||
|
||||
// Get retrieves the object by its kind, namespace and name.
|
||||
Get(gvk unversioned.GroupVersionKind, ns, name string) (runtime.Object, error)
|
||||
Get(gvk schema.GroupVersionKind, ns, name string) (runtime.Object, error)
|
||||
|
||||
// Update updates an existing object in the tracker.
|
||||
Update(obj runtime.Object) error
|
||||
|
||||
// List retrieves all objects of a given kind in the given
|
||||
// namespace. Only non-List kinds are accepted.
|
||||
List(gvk unversioned.GroupVersionKind, ns string) (runtime.Object, error)
|
||||
List(gvk schema.GroupVersionKind, ns string) (runtime.Object, error)
|
||||
|
||||
// Delete deletes an existing object from the tracker. If object
|
||||
// didn't exist in the tracker prior to deletion, Delete returns
|
||||
// no error.
|
||||
Delete(gvk unversioned.GroupVersionKind, ns, name string) error
|
||||
Delete(gvk schema.GroupVersionKind, ns, name string) error
|
||||
}
|
||||
|
||||
// ObjectScheme abstracts the implementation of common operations on objects.
|
||||
@@ -143,7 +144,7 @@ type tracker struct {
|
||||
scheme ObjectScheme
|
||||
decoder runtime.Decoder
|
||||
lock sync.RWMutex
|
||||
objects map[unversioned.GroupVersionKind][]runtime.Object
|
||||
objects map[schema.GroupVersionKind][]runtime.Object
|
||||
}
|
||||
|
||||
var _ ObjectTracker = &tracker{}
|
||||
@@ -154,11 +155,11 @@ func NewObjectTracker(scheme ObjectScheme, decoder runtime.Decoder) ObjectTracke
|
||||
return &tracker{
|
||||
scheme: scheme,
|
||||
decoder: decoder,
|
||||
objects: make(map[unversioned.GroupVersionKind][]runtime.Object),
|
||||
objects: make(map[schema.GroupVersionKind][]runtime.Object),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tracker) List(gvk unversioned.GroupVersionKind, ns string) (runtime.Object, error) {
|
||||
func (t *tracker) List(gvk schema.GroupVersionKind, ns string) (runtime.Object, error) {
|
||||
// Heuristic for list kind: original kind + List suffix. Might
|
||||
// not always be true but this tracker has a pretty limited
|
||||
// understanding of the actual API model.
|
||||
@@ -195,12 +196,12 @@ func (t *tracker) List(gvk unversioned.GroupVersionKind, ns string) (runtime.Obj
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (t *tracker) Get(gvk unversioned.GroupVersionKind, ns, name string) (runtime.Object, error) {
|
||||
func (t *tracker) Get(gvk schema.GroupVersionKind, ns, name string) (runtime.Object, error) {
|
||||
if err := checkNamespace(gvk, ns); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
errNotFound := errors.NewNotFound(unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, name)
|
||||
errNotFound := errors.NewNotFound(schema.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, name)
|
||||
|
||||
t.lock.RLock()
|
||||
defer t.lock.RUnlock()
|
||||
@@ -266,7 +267,7 @@ func (t *tracker) add(obj runtime.Object, replaceExisting bool) error {
|
||||
defer t.lock.Unlock()
|
||||
|
||||
for _, gvk := range gvks {
|
||||
gr := unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}
|
||||
gr := schema.GroupResource{Group: gvk.Group, Resource: gvk.Kind}
|
||||
|
||||
// To avoid the object from being accidentally modified by caller
|
||||
// after it's been added to the tracker, we always store the deep
|
||||
@@ -332,7 +333,7 @@ func (t *tracker) addList(obj runtime.Object, replaceExisting bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tracker) Delete(gvk unversioned.GroupVersionKind, ns, name string) error {
|
||||
func (t *tracker) Delete(gvk schema.GroupVersionKind, ns, name string) error {
|
||||
if err := checkNamespace(gvk, ns); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -358,7 +359,7 @@ func (t *tracker) Delete(gvk unversioned.GroupVersionKind, ns, name string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.NewNotFound(unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, name)
|
||||
return errors.NewNotFound(schema.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, name)
|
||||
}
|
||||
|
||||
// filterByNamespaceAndName returns all objects in the collection that
|
||||
@@ -387,7 +388,7 @@ func filterByNamespaceAndName(objs []runtime.Object, ns, name string) ([]runtime
|
||||
// checkNamespace makes sure that the scope of gvk matches ns. It
|
||||
// returns an error if namespace is empty but gvk is a namespaced
|
||||
// kind, or if ns is non-empty and gvk is a namespaced kind.
|
||||
func checkNamespace(gvk unversioned.GroupVersionKind, ns string) error {
|
||||
func checkNamespace(gvk schema.GroupVersionKind, ns string) error {
|
||||
group, err := registered.Group(gvk.Group)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user