fake

package
v0.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Registry is an instance of an API registry.
	Registry = registered.NewOrDie("")
	// Scheme for API object types
	Scheme = runtime.NewScheme()
	// ParameterCodec handles versioning of objects that are converted to query parameters.
	ParameterCodec = runtime.NewParameterCodec(Scheme)
	// Codecs for creating a server config
	Codecs = serializer.NewCodecFactory(Scheme)
)

Functions

This section is empty.

Types

type NamespacedStorage

type NamespacedStorage map[string]TypedStorage

NamespacedStorage is a map of namespaces to TypedStorage

func (NamespacedStorage) Delete

func (s NamespacedStorage) Delete(ns, tipe, name string)

Delete removes an object from storage, given a namepace, type, and name

func (NamespacedStorage) Get

func (s NamespacedStorage) Get(ns, tipe, name string) runtime.Object

Get returns an object from storage, given a namespace, type, and name

func (NamespacedStorage) GetList

func (s NamespacedStorage) GetList(ns, tipe string) []runtime.Object

GetList returns a list of objects from storage, given a namespace and a type

func (NamespacedStorage) Set

func (s NamespacedStorage) Set(ns, tipe, name string, obj runtime.Object)

Set adds an object to storage, given a namespace, type, and name

type ObjStorage

type ObjStorage map[string]runtime.Object

ObjStorage is a map of object names to objects

type RESTClient

type RESTClient struct {
	Storage NamespacedStorage
	Watcher *Watcher

	*fakerestclient.RESTClient
	// contains filtered or unexported fields
}

RESTClient is a fake implementation of rest.Interface used to facilitate testing. It short-circuits all HTTP requests that would ordinarily go upstream to a core apiserver. It muxes those requests in-process, uses in-memory storage, and responds just as a core apiserver would.

func NewRESTClient

func NewRESTClient(newEmptyObj func() runtime.Object) *RESTClient

NewRESTClient returns a new FakeCoreRESTClient

type TypedStorage

type TypedStorage map[string]ObjStorage

TypedStorage is a map of types to ObjStorage

func NewTypedStorage

func NewTypedStorage() TypedStorage

NewTypedStorage returns a new TypedStorage

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is a completely in-memory watcher mechanism for use in the fake REST client. This construct sends and receives on the same stream regardless of the type of object, its namespace, or anything else.

Also note that this is not the same thing as a watch.Interface.

func NewWatcher

func NewWatcher() *Watcher

NewWatcher creates a new Watcher with no events in it

func (*Watcher) Close

func (w *Watcher) Close()

Close closes this watcher. All calls to SendObject after this func is called will cause a panic, and all channels returned by ReceiveChan, before or after this function is called, will be closed

func (*Watcher) ReceiveChan

func (w *Watcher) ReceiveChan() <-chan watch.Event

ReceiveChan returns a read-only channel that can be used to receive events sent via this watcher

func (*Watcher) SendObject

func (w *Watcher) SendObject(evtType watch.EventType, obj runtime.Object, timeout time.Duration) error

SendObject sends a watch event of evtType with object obj. It returns an error if the send couldn't be completed within timeout

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL