Documentation
¶
Index ¶
- func AddObjectsFromPath(path string, o ObjectRetriever, decoder runtime.Decoder) error
- type Action
- type ActionImpl
- type CreateAction
- type CreateActionImpl
- type DeleteAction
- type DeleteActionImpl
- type DeleteCollectionActionImpl
- type Fake
- func (c *Fake) Actions() []Action
- func (c *Fake) AddProxyReactor(resource string, reaction ProxyReactionFunc)
- func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc)
- func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc)
- func (c *Fake) ClearActions()
- func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error)
- func (c *Fake) InvokesProxy(action Action) restclient.ResponseWrapper
- func (c *Fake) InvokesWatch(action Action) (watch.Interface, error)
- func (c *Fake) PrependProxyReactor(resource string, reaction ProxyReactionFunc)
- func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc)
- func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc)
- type FakeDiscovery
- func (c *FakeDiscovery) ServerGroups() (*unversioned.APIGroupList, error)
- func (c *FakeDiscovery) ServerResources() (map[string]*unversioned.APIResourceList, error)
- func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error)
- func (c *FakeDiscovery) ServerVersion() (*version.Info, error)
- type GenericAction
- type GenericActionImpl
- type GetAction
- type GetActionImpl
- type ListAction
- type ListActionImpl
- type ListRestrictions
- type ObjectRetriever
- type ObjectScheme
- type PatchActionImpl
- func NewPatchAction(resource unversioned.GroupVersionResource, namespace string, ...) PatchActionImpl
- func NewPatchSubresourceAction(resource unversioned.GroupVersionResource, subresource string) PatchActionImpl
- func NewRootPatchAction(resource unversioned.GroupVersionResource, object runtime.Object) PatchActionImpl
- type ProxyGetAction
- type ProxyGetActionImpl
- type ProxyReactionFunc
- type ProxyReactor
- type ReactionFunc
- type Reactor
- type SimpleProxyReactor
- type SimpleReactor
- type SimpleWatchReactor
- type UpdateAction
- type UpdateActionImpl
- func NewRootUpdateAction(resource unversioned.GroupVersionResource, object runtime.Object) UpdateActionImpl
- func NewRootUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, ...) UpdateActionImpl
- func NewUpdateAction(resource unversioned.GroupVersionResource, namespace string, ...) UpdateActionImpl
- func NewUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, ...) UpdateActionImpl
- type WatchAction
- type WatchActionImpl
- type WatchReactionFunc
- type WatchReactor
- type WatchRestrictions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddObjectsFromPath ¶
func AddObjectsFromPath(path string, o ObjectRetriever, decoder runtime.Decoder) error
AddObjectsFromPath loads the JSON or YAML file containing Kubernetes API resources and adds them to the provided ObjectRetriever.
Types ¶
type Action ¶
type Action interface {
GetNamespace() string
GetVerb() string
GetResource() unversioned.GroupVersionResource
GetSubresource() string
Matches(verb, resource string) bool
}
type ActionImpl ¶
type ActionImpl struct {
Namespace string
Verb string
Resource unversioned.GroupVersionResource
Subresource string
}
func (ActionImpl) GetNamespace ¶
func (a ActionImpl) GetNamespace() string
func (ActionImpl) GetResource ¶
func (a ActionImpl) GetResource() unversioned.GroupVersionResource
func (ActionImpl) GetSubresource ¶
func (a ActionImpl) GetSubresource() string
type CreateAction ¶
type CreateAction interface {
Action
GetObject() runtime.Object
}
type CreateActionImpl ¶
type CreateActionImpl struct {
ActionImpl
Object runtime.Object
}
func NewCreateAction ¶
func NewCreateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) CreateActionImpl
func NewRootCreateAction ¶
func NewRootCreateAction(resource unversioned.GroupVersionResource, object runtime.Object) CreateActionImpl
type DeleteAction ¶
type DeleteAction interface {
Action
GetName() string
}
type DeleteActionImpl ¶
type DeleteActionImpl struct {
ActionImpl
Name string
}
func NewDeleteAction ¶
func NewDeleteAction(resource unversioned.GroupVersionResource, namespace, name string) DeleteActionImpl
func NewRootDeleteAction ¶
func NewRootDeleteAction(resource unversioned.GroupVersionResource, name string) DeleteActionImpl
type DeleteCollectionActionImpl ¶
type DeleteCollectionActionImpl struct {
ActionImpl
ListRestrictions ListRestrictions
}
func NewDeleteCollectionAction ¶
func NewDeleteCollectionAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) DeleteCollectionActionImpl
func NewRootDeleteCollectionAction ¶
func NewRootDeleteCollectionAction(resource unversioned.GroupVersionResource, opts api.ListOptions) DeleteCollectionActionImpl
func (DeleteCollectionActionImpl) GetListRestrictions ¶
func (a DeleteCollectionActionImpl) GetListRestrictions() ListRestrictions
type Fake ¶
type Fake struct {
sync.RWMutex
// ReactionChain is the list of reactors that will be attempted for every request in the order they are tried
ReactionChain []Reactor
// WatchReactionChain is the list of watch reactors that will be attempted for every request in the order they are tried
WatchReactionChain []WatchReactor
// ProxyReactionChain is the list of proxy reactors that will be attempted for every request in the order they are tried
ProxyReactionChain []ProxyReactor
Resources map[string]*unversioned.APIResourceList
// contains filtered or unexported fields
}
Fake implements client.Interface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.
func (*Fake) Actions ¶
func (c *Fake) Actions() []Action
Actions returns a chronologically ordered slice fake actions called on the fake client
func (*Fake) AddProxyReactor ¶
func (c *Fake) AddProxyReactor(resource string, reaction ProxyReactionFunc)
AddProxyReactor appends a reactor to the end of the chain
func (*Fake) AddReactor ¶
func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc)
AddReactor appends a reactor to the end of the chain
func (*Fake) AddWatchReactor ¶
func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc)
AddWatchReactor appends a reactor to the end of the chain
func (*Fake) ClearActions ¶
func (c *Fake) ClearActions()
ClearActions clears the history of actions called on the fake client
func (*Fake) Invokes ¶
func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error)
Invokes records the provided Action and then invokes the ReactFn (if provided). defaultReturnObj is expected to be of the same type a normal call would return.
func (*Fake) InvokesProxy ¶
func (c *Fake) InvokesProxy(action Action) restclient.ResponseWrapper
InvokesProxy records the provided Action and then invokes the ReactFn (if provided).
func (*Fake) InvokesWatch ¶
func (c *Fake) InvokesWatch(action Action) (watch.Interface, error)
InvokesWatch records the provided Action and then invokes the ReactFn (if provided).
func (*Fake) PrependProxyReactor ¶
func (c *Fake) PrependProxyReactor(resource string, reaction ProxyReactionFunc)
PrependProxyReactor adds a reactor to the beginning of the chain
func (*Fake) PrependReactor ¶
func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc)
PrependReactor adds a reactor to the beginning of the chain
func (*Fake) PrependWatchReactor ¶
func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc)
PrependWatchReactor adds a reactor to the beginning of the chain
type FakeDiscovery ¶
type FakeDiscovery struct {
*Fake
}
TODO: this probably should be moved to somewhere else.
func (*FakeDiscovery) ServerGroups ¶
func (c *FakeDiscovery) ServerGroups() (*unversioned.APIGroupList, error)
func (*FakeDiscovery) ServerResources ¶
func (c *FakeDiscovery) ServerResources() (map[string]*unversioned.APIResourceList, error)
func (*FakeDiscovery) ServerResourcesForGroupVersion ¶
func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error)
func (*FakeDiscovery) ServerVersion ¶
func (c *FakeDiscovery) ServerVersion() (*version.Info, error)
type GenericAction ¶
type GenericAction interface {
Action
GetValue() interface{}
}
type GenericActionImpl ¶
type GenericActionImpl struct {
ActionImpl
Value interface{}
}
type GetActionImpl ¶
type GetActionImpl struct {
ActionImpl
Name string
}
func NewGetAction ¶
func NewGetAction(resource unversioned.GroupVersionResource, namespace, name string) GetActionImpl
func NewRootGetAction ¶
func NewRootGetAction(resource unversioned.GroupVersionResource, name string) GetActionImpl
type ListAction ¶
type ListAction interface {
Action
GetListRestrictions() ListRestrictions
}
type ListActionImpl ¶
type ListActionImpl struct {
ActionImpl
ListRestrictions ListRestrictions
}
func NewListAction ¶
func NewListAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) ListActionImpl
func NewRootListAction ¶
func NewRootListAction(resource unversioned.GroupVersionResource, opts api.ListOptions) ListActionImpl
func (ListActionImpl) GetListRestrictions ¶
func (a ListActionImpl) GetListRestrictions() ListRestrictions
type ListRestrictions ¶
type ListRestrictions struct {
Labels labels.Selector
Fields fields.Selector
}
type ObjectRetriever ¶
type ObjectRetriever interface {
// Kind should return a resource or a list of resources (depending on the provided kind and
// name). It should return an error if the caller should communicate an error to the server.
Kind(gvk unversioned.GroupVersionKind, name string) (runtime.Object, error)
// Add adds a runtime object for test purposes into this object.
Add(runtime.Object) error
}
ObjectRetriever abstracts the implementation for retrieving or setting generic objects. It is intended to be used to fake calls to a server by returning objects based on their kind and name.
func NewObjects ¶
func NewObjects(scheme ObjectScheme, decoder runtime.Decoder) ObjectRetriever
NewObjects implements the ObjectRetriever interface by introspecting the objects provided to Add() and returning them when the Kind method is invoked. If an api.List object is provided to Add(), each child item is added. If an object is added that is itself a list (PodList, ServiceList) then that is added to the "PodList" kind. If no PodList is added, the retriever will take any loaded Pods and return them in a list. If an api.Status is added, and the Details.Kind field is set, that status will be returned instead (as an error if Status != Success, or as a runtime.Object if Status == Success). If multiple PodLists are provided, they will be returned in order by the Kind call, and the last PodList will be reused for subsequent calls.
type ObjectScheme ¶
type ObjectScheme interface {
runtime.ObjectCreater
runtime.ObjectCopier
runtime.ObjectTyper
}
ObjectScheme abstracts the implementation of common operations on objects.
type PatchActionImpl ¶
type PatchActionImpl struct {
ActionImpl
Object runtime.Object
}
func NewPatchAction ¶
func NewPatchAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) PatchActionImpl
func NewPatchSubresourceAction ¶ added in v1.3.0
func NewPatchSubresourceAction(resource unversioned.GroupVersionResource, subresource string) PatchActionImpl
func NewRootPatchAction ¶
func NewRootPatchAction(resource unversioned.GroupVersionResource, object runtime.Object) PatchActionImpl
type ProxyGetAction ¶
type ProxyGetAction interface {
Action
GetScheme() string
GetName() string
GetPort() string
GetPath() string
GetParams() map[string]string
}
type ProxyGetActionImpl ¶
type ProxyGetActionImpl struct {
ActionImpl
Scheme string
Name string
Port string
Path string
Params map[string]string
}
func NewProxyGetAction ¶
func NewProxyGetAction(resource unversioned.GroupVersionResource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl
type ProxyReactionFunc ¶
type ProxyReactionFunc func(action Action) (handled bool, ret restclient.ResponseWrapper, err error)
ProxyReactionFunc is a function that returns a ResponseWrapper interface for a given Action. If "handled" is false, then the test client will continue ignore the results and continue to the next ProxyReactionFunc
type ProxyReactor ¶
type ProxyReactor interface {
// Handles indicates whether or not this Reactor deals with a given action
Handles(action Action) bool
// React handles a watch action and returns results. It may choose to delegate by indicated handled=false
React(action Action) (handled bool, ret restclient.ResponseWrapper, err error)
}
ProxyReactor is an interface to allow the composition of proxy get functions.
type ReactionFunc ¶
type ReactionFunc func(action Action) (handled bool, ret runtime.Object, err error)
ReactionFunc is a function that returns an object or error for a given Action. If "handled" is false, then the test client will continue ignore the results and continue to the next ReactionFunc
func ObjectReaction ¶
func ObjectReaction(o ObjectRetriever, mapper meta.RESTMapper) ReactionFunc
ObjectReaction returns a ReactionFunc that takes a generic action string of the form <verb>-<resource> or <verb>-<subresource>-<resource> and attempts to return a runtime Object or error that matches the requested action. For instance, list-replicationControllers should attempt to return a list of replication controllers. This method delegates to the ObjectRetriever interface to satisfy retrieval of lists or retrieval of single items. TODO: add support for sub resources
type Reactor ¶
type Reactor interface {
// Handles indicates whether or not this Reactor deals with a given action
Handles(action Action) bool
// React handles the action and returns results. It may choose to delegate by indicated handled=false
React(action Action) (handled bool, ret runtime.Object, err error)
}
Reactor is an interface to allow the composition of reaction functions.
type SimpleProxyReactor ¶
type SimpleProxyReactor struct {
Resource string
Reaction ProxyReactionFunc
}
SimpleProxyReactor is a ProxyReactor. Each reaction function is attached to a given resource. "*" matches everything for that value. For instance, *,pods matches all verbs on pods. This allows for easier composition of reaction functions.
type SimpleReactor ¶
type SimpleReactor struct {
Verb string
Resource string
Reaction ReactionFunc
}
SimpleReactor is a Reactor. Each reaction function is attached to a given verb,resource tuple. "*" in either field matches everything for that value. For instance, *,pods matches all verbs on pods. This allows for easier composition of reaction functions
type SimpleWatchReactor ¶
type SimpleWatchReactor struct {
Resource string
Reaction WatchReactionFunc
}
SimpleWatchReactor is a WatchReactor. Each reaction function is attached to a given resource. "*" matches everything for that value. For instance, *,pods matches all verbs on pods. This allows for easier composition of reaction functions
type UpdateAction ¶
type UpdateAction interface {
Action
GetObject() runtime.Object
}
type UpdateActionImpl ¶
type UpdateActionImpl struct {
ActionImpl
Object runtime.Object
}
func NewRootUpdateAction ¶
func NewRootUpdateAction(resource unversioned.GroupVersionResource, object runtime.Object) UpdateActionImpl
func NewRootUpdateSubresourceAction ¶
func NewRootUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, object runtime.Object) UpdateActionImpl
func NewUpdateAction ¶
func NewUpdateAction(resource unversioned.GroupVersionResource, namespace string, object runtime.Object) UpdateActionImpl
func NewUpdateSubresourceAction ¶
func NewUpdateSubresourceAction(resource unversioned.GroupVersionResource, subresource string, namespace string, object runtime.Object) UpdateActionImpl
type WatchAction ¶
type WatchAction interface {
Action
GetWatchRestrictions() WatchRestrictions
}
type WatchActionImpl ¶
type WatchActionImpl struct {
ActionImpl
WatchRestrictions WatchRestrictions
}
func NewRootWatchAction ¶
func NewRootWatchAction(resource unversioned.GroupVersionResource, opts api.ListOptions) WatchActionImpl
func NewWatchAction ¶
func NewWatchAction(resource unversioned.GroupVersionResource, namespace string, opts api.ListOptions) WatchActionImpl
func (WatchActionImpl) GetWatchRestrictions ¶
func (a WatchActionImpl) GetWatchRestrictions() WatchRestrictions
type WatchReactionFunc ¶
type WatchReactionFunc func(action Action) (handled bool, ret watch.Interface, err error)
WatchReactionFunc is a function that returns a watch interface. If "handled" is false, then the test client will continue ignore the results and continue to the next ReactionFunc
func DefaultWatchReactor ¶
func DefaultWatchReactor(watchInterface watch.Interface, err error) WatchReactionFunc
type WatchReactor ¶
type WatchReactor interface {
// Handles indicates whether or not this Reactor deals with a given action
Handles(action Action) bool
// React handles a watch action and returns results. It may choose to delegate by indicated handled=false
React(action Action) (handled bool, ret watch.Interface, err error)
}
WatchReactor is an interface to allow the composition of watch functions.
type WatchRestrictions ¶
type WatchRestrictions struct {
Labels labels.Selector
Fields fields.Selector
ResourceVersion string
}