fakes

package
v3.9.9 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fakes defines methods for instantiating objects which act like resources on a Kubernetes cluster, but are not intended to actually be instantiated on a real, production cluster.

The primary purpose of these objects is to aid writing tests, but that is not this package's only purpose. These objects are also used in debugging logic which is compiled in to production code.

Index

Constants

View Source
const (
	// Name is the default name given to fake objects.
	Name = "foo"

	// Namespace is the default namespace given to fake namespace-scoped objects.
	Namespace = "bar"

	// UID is the default UID given to fake objects.
	UID = "abcd"
)
View Source
const (
	// ExternalDataProviderName is the name of the fake external data provider.
	ExternalDataProviderName = "test-provider"
)

Variables

View Source
var ExternalDataProviderCache = frameworksexternaldata.NewCache()

ExternalDataProviderCache is the cache of external data providers.

Functions

func Pod

func Pod(opts ...Opt) *corev1.Pod

Pod creates a Pod for use in testing or debugging logic.

Types

type Opt

type Opt func(client.Object)

Opt modifies a client.Object during object instantiation. Generally, if there are conflicting opts (such as two WithName calls), the latter should win. This allows objects to have defaults which can easily be overridden.

func WithLabels

func WithLabels(labels map[string]string) Opt

WithLabels sets the metadata.labels of the object. Overwrites any existing labels on the object.

func WithName

func WithName(name string) Opt

WithName sets the metadata.name of the object.

func WithNamespace

func WithNamespace(namespace string) Opt

WithNamespace sets the metadata.namespace of the object.

func WithUID

func WithUID(uid types.UID) Opt

WithUID sets the metadata.uid of the object.

Jump to

Keyboard shortcuts

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