clusterenv

package
v0.0.0-...-4c7e981 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0, Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package clusterenv supports controller tests against a real Kubernetes cluster. Cluster and image lifecycle remain external.

Index

Constants

View Source
const (
	// ContextEnvVar names the kubeconfig context explicitly unlocked for cluster tests.
	ContextEnvVar = "DYNAMO_CLUSTERTEST_CONTEXT"
)

Variables

This section is empty.

Functions

func RequireEnv

func RequireEnv(tb testing.TB, name string) string

RequireEnv returns a required cluster-test environment variable.

Types

type Env

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

Env lazily connects to one externally managed Kubernetes cluster.

func New

func New(opts Options) *Env

New returns an Env configured with opts.

func (*Env) RunM

func (e *Env) RunM(m *testing.M) int

RunM owns the shared cluster connection and webhook runtime for one package.

func (*Env) RunT

func (e *Env) RunT(tb testing.TB) *TestEnv

RunT creates a namespace and returns a test environment backed by the explicitly unlocked cluster context.

type Options

type Options struct {
	Scheme                 *runtime.Scheme
	SetupWebhooks          func(ctrl.Manager) error
	AdditionalAdmission    webhookconfig.Configurations
	WebhookProxyImage      string
	EventuallyTimeout      time.Duration
	NamespaceDeleteTimeout time.Duration
}

Options configures an Env.

type TestEnv

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

TestEnv provides a dedicated namespace and a controller manager for one test.

func (*TestEnv) BlockReplicaSets

func (e *TestEnv) BlockReplicaSets()

BlockReplicaSets prevents Deployments from being actuated while allowing Job-backed tests to run Pods in the test namespace.

func (*TestEnv) BlockWorkloads

func (e *TestEnv) BlockWorkloads()

BlockWorkloads prevents controllers from creating ReplicaSets and Pods in the test namespace without changing the workload manifests under test.

func (*TestEnv) Client

func (e *TestEnv) Client() client.Client

Client returns an unrestricted client for the selected cluster. Tests must use Namespace for namespaced fixtures.

func (*TestEnv) Namespace

func (e *TestEnv) Namespace() string

Namespace returns the namespace dedicated to this test.

func (*TestEnv) RESTConfig

func (e *TestEnv) RESTConfig() *rest.Config

RESTConfig returns a copy of the selected cluster REST configuration.

func (*TestEnv) StartManager

func (e *TestEnv) StartManager(setup func(ctrl.Manager) error)

StartManager starts one namespace-scoped controller manager configured by setup.

Jump to

Keyboard shortcuts

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