testobj

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUnstructured

func GetUnstructured(scheme *runtime.Scheme, obj runtime.Object) *unstructured.Unstructured

GetUnstructured gets an Unstructured for the given object and panics if it fails.

func MarshalJSON

func MarshalJSON(obj runtime.Object) (marshaled []byte)

MarshalJSON marshals an object to JSON and panics if it can't.

func NamespacedName

func NamespacedName(obj runtime.Object) types.NamespacedName

NamespacedName returns the namespaced name of the given object and panics if it can't access the object's meta.

func StripLabel

func StripLabel(key string, objs ...runtime.Object) (stripped []runtime.Object)

StripLabel removes the label with the given key from each object given and panics if it can't access an object's meta.

func WithItems

func WithItems(list runtime.Object, items ...runtime.Object) runtime.Object

WithItems sets the items of the list given and panics if it fails.

func WithLabel

func WithLabel(key, value string, objs ...runtime.Object) (labelled []runtime.Object)

WithLabel sets the given key/value pair on the labels of each object given and panics if it can't access an object's meta.

func WithName

func WithName(name string, obj runtime.Object) runtime.Object

WithName sets the name of the given object and panics if it can't access the object's meta.

Types

type FixtureFiller

type FixtureFiller interface {
	// NewFixture populates a given fixture.
	Fill(fixture RuntimeMetaObject) RuntimeMetaObject
}

FixtureFiller knows how to fill fixtures.

type FixtureFillerConfig

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

FixtureFillerConfig holds the configuration needed to build a FixtureFiller.

type FixtureFillerFunc

type FixtureFillerFunc func(fixture RuntimeMetaObject) RuntimeMetaObject

FixtureFillerFunc is a function that implements FixtureFiller.

func (FixtureFillerFunc) Fill

Fill invokes a FixtureFillerFunc on a fixture.

type FixtureFillerOption

type FixtureFillerOption func(*FixtureFillerConfig)

FixtureFillerOption represents a configuration option for building a FixtureFiller.

func WithFixture

func WithFixture(fixture RuntimeMetaObject) FixtureFillerOption

WithFixture configures a FixtureFiller to copy the contents of the given fixture to fixtures of the same type.

func WithFixtureFile

func WithFixtureFile(fixture RuntimeMetaObject, file string) FixtureFillerOption

WithFixtureFile configures a FixtureFiller to use a file to populate fixtures of a given type.

type PrototypeFiller

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

PrototypeFiller is a Filler that copies existing fields from a prototypical instance of a fixture.

func (*PrototypeFiller) Fill

Fill populates a fixture by copying a prototypical fixture. Panics if a given fixture is not the same type as the prototype.

type RuntimeMetaObject

type RuntimeMetaObject interface {
	runtime.Object
	metav1.Object
}

RuntimeMetaObject is an object with both runtime and metadata level info.

func WithLabels

func WithLabels(labels map[string]string, obj RuntimeMetaObject) RuntimeMetaObject

WithLabels sets the labels of an object and returns the updated result.

func WithNamespace

func WithNamespace(namespace string, obj runtime.Object) RuntimeMetaObject

WithNamespace sets the namespace of the given object and panics if it can't access the object's meta.

func WithNamespacedName

func WithNamespacedName(name *types.NamespacedName, obj runtime.Object) RuntimeMetaObject

WithNamespacedName sets the namespace and name of the given object.

func WithOwner

func WithOwner(owner, obj RuntimeMetaObject) RuntimeMetaObject

WithOwner appends the an owner to an object and returns a panic if it fails.

type TypedFixtureFiller

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

TypedFixtureFiller is a set of fillers keyed by fixture type.

func NewFixtureFiller

func NewFixtureFiller(options ...FixtureFillerOption) *TypedFixtureFiller

NewFixtureFiller builds and returns a new FixtureFiller.

func (*TypedFixtureFiller) Fill

Fill populates a fixture if an associated filler has been defined for its type. Panics if there's no filler defined for the fixture type.

Jump to

Keyboard shortcuts

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