gentest

package
v2.11.26 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package gentest contains tests for the client generator.

Index

Constants

This section is empty.

Variables

View Source
var (
	ConditionReady       = apis.ConditionType("Ready")
	ConditionInitialized = apis.ConditionType(v1.PodInitialized)
)

Functions

func ConditionDeleted

func ConditionDeleted(ctx context.Context, _ *v1.Pod, apiErr error) (bool, error)

ConditionDeleted is a ConditionFuncE that succeeds if the error returned by the cluster was a not found error.

func ConditionInitializedTrue

func ConditionInitializedTrue(ctx context.Context, obj *v1.Pod, err error) (bool, error)

ConditionInitializedTrue is a ConditionFuncE that waits for Condition{Initialized v1.PodInitialized } to become true and fails with an error if the condition becomes false.

func ConditionReadyTrue

func ConditionReadyTrue(ctx context.Context, obj *v1.Pod, err error) (bool, error)

ConditionReadyTrue is a ConditionFuncE that waits for Condition{Ready Ready} to become true and fails with an error if the condition becomes false.

func ExtractConditions

func ExtractConditions(obj *v1.Pod) (extracted []apis.Condition)

ExtractConditions converts the native condition types into an apis.Condition array with the Type, Status, Reason, and Message fields intact.

func ObservedGenerationMatchesGeneration

func ObservedGenerationMatchesGeneration(obj *v1.Pod) bool

ObservedGenerationMatchesGeneration is a predicate that returns true if the object's ObservedGeneration matches the genration of the object.

func WithConditionReporter added in v2.11.16

func WithConditionReporter(ctx context.Context, reporter ConditionReporter) context.Context

WithConditionReporter adds a callback to condition waits.

Types

type Client

type Client interface {
	Create(ctx context.Context, namespace string, obj *v1.Pod) (*v1.Pod, error)
	Transform(ctx context.Context, namespace string, name string, transformer Mutator) (*v1.Pod, error)
	Get(ctx context.Context, namespace string, name string) (*v1.Pod, error)
	Delete(ctx context.Context, namespace string, name string) error
	List(ctx context.Context, namespace string) ([]v1.Pod, error)
	Upsert(ctx context.Context, namespace string, newObj *v1.Pod, merge Merger) (*v1.Pod, error)
	WaitFor(ctx context.Context, namespace string, name string, interval time.Duration, condition Predicate) (*v1.Pod, error)

	// Utility functions
	WaitForDeletion(ctx context.Context, namespace string, name string, interval time.Duration) (*v1.Pod, error)
	WaitForConditionReadyTrue(ctx context.Context, namespace string, name string, interval time.Duration) (*v1.Pod, error)
	WaitForConditionInitializedTrue(ctx context.Context, namespace string, name string, interval time.Duration) (*v1.Pod, error)

	// ClientExtension can be used by the developer to extend the client.
	ClientExtension
}

Client is the interface for interacting with v1.Pod types as OperatorConfig CF style objects.

func NewExampleClient

func NewExampleClient(mockK8s v1.PodsGetter) Client

NewExampleClient creates an example client with a mutator and membership validator that filter based on a label.

type ClientExtension

type ClientExtension interface {
}

type ConditionFuncE

type ConditionFuncE func(ctx context.Context, instance *v1.Pod, apiErr error) (done bool, err error)

ConditionFuncE is a callback used by waitForE. Done should be set to true once the condition succeeds and shouldn't be called anymore. The error will be passed back to the user.

This function MAY retrieve a nil instance and an apiErr. It's up to the function to decide how to handle the apiErr.

type ConditionReporter added in v2.11.16

type ConditionReporter func(message string)

ConditionReporter reports on changes to conditions while waiting.

type Merger

type Merger func(newObj, oldObj *v1.Pod) *v1.Pod

Merger is a type to merge an existing value with a new one.

type Mutator

type Mutator func(*v1.Pod) error

Mutator is a function that changes v1.Pod.

type Predicate

type Predicate func(*v1.Pod) bool

Predicate is a boolean function for a v1.Pod.

type ResourceInfo

type ResourceInfo struct{}

func NewResourceInfo

func NewResourceInfo() *ResourceInfo

NewResourceInfo returns a new instance of ResourceInfo

func (*ResourceInfo) FriendlyName

func (*ResourceInfo) FriendlyName() string

FriendlyName gets the user-facing name of the resource.

func (*ResourceInfo) GroupVersionKind

func (*ResourceInfo) GroupVersionKind(context.Context) schema.GroupVersionKind

GroupVersionKind gets the GVK struct for the resource.

func (*ResourceInfo) GroupVersionResource

func (*ResourceInfo) GroupVersionResource(context.Context) schema.GroupVersionResource

GroupVersionResource gets the GVR struct for the resource.

func (*ResourceInfo) Namespaced

func (*ResourceInfo) Namespaced() bool

Namespaced returns true if the type belongs in a namespace.

Jump to

Keyboard shortcuts

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