loader

package
v0.0.0-...-ef6dcbe Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMockedContext

func GetMockedContext(ctx context.Context, data []MockData) context.Context

GetMockedContext creates a new context with the given MockData items.

func GetMockedResourceAndErrorFromContext

func GetMockedResourceAndErrorFromContext[T any](ctx context.Context, contextKey ContextKey, _ T) (T, error)

GetMockedResourceAndErrorFromContext returns the mocked data found in the context passed as an argument. The data is to be found in the contextDataKey key. If not there, a panic will be raised.

func GetObject

func GetObject(name, namespace string, cli client.Client, ctx context.Context, object client.Object) error

GetObject loads an object from the cluster. This is a generic function that requires the object to be passed as an argument. The object is modified during the invocation.

Types

type ContextKey

type ContextKey int

ContextKey is a kye that will be used within a context to reference a MockData item.

type MockData

type MockData struct {
	ContextKey ContextKey
	Err        error
	Resource   any
}

MockData represents the mocked data that will be returned by a mocked loader method.

Jump to

Keyboard shortcuts

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