reality

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFlushError = errorx.NewType(ErrNamespace, "flush_error")
View Source
var ErrNamespace = errorx.NewNamespace("reality")

Functions

func UnmarshalManifest

func UnmarshalManifest(manifest string) ([]*unstructured.Unstructured, error)

UnmarshalManifest parses a Helm release manifest (possibly multi-doc YAML) and returns a slice of Unstructured objects (one per non-empty document).

Types

type Base

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

type Checker

type Checker[T any] interface {
	FlushState(st T) error
	RefreshState(ctx context.Context) (T, error)
}

Checker is the composite abstraction for accessing the current state of the

func NewBlockNodeChecker

func NewBlockNodeChecker(
	sm state.Manager,
	newHelm func() (HelmManager, error),
	newKube func() (KubeClient, error),
	clusterExists ClusterProbe,
) (Checker[state.BlockNodeState], error)

NewBlockNodeChecker constructs a blockNodeChecker. In production pass helm2.NewManager, kube.NewClient and kube.ClusterExists. In tests swap them for fakes.

func NewClusterChecker

func NewClusterChecker(sm state.Manager, clusterExists ClusterProbe) (Checker[state.ClusterState], error)

NewClusterChecker constructs a clusterChecker with the given probe. In production pass kube.ClusterExists; in tests pass a fake.

func NewMachineChecker

func NewMachineChecker(sm state.Manager, sandboxBinDir, stateDir string) (Checker[state.MachineState], error)

NewMachineChecker constructs a machineChecker. sandboxBinDir and stateDir may be empty strings; the checker will fall back to models.Paths() values at call time.

type CheckerOption

type CheckerOption func(*checkerConfig)

CheckerOption configures the Checker.

func WithClusterProbe

func WithClusterProbe(fn ClusterProbe) CheckerOption

func WithHelmFactory

func WithHelmFactory(fn func() (HelmManager, error)) CheckerOption

func WithKubeFactory

func WithKubeFactory(fn func() (KubeClient, error)) CheckerOption

func WithSandboxBinDir

func WithSandboxBinDir(dir string) CheckerOption

func WithStateDir

func WithStateDir(dir string) CheckerOption

type Checkers

type Checkers struct {
	Cluster   Checker[state.ClusterState]
	Machine   Checker[state.MachineState]
	BlockNode Checker[state.BlockNodeState]
}

Checkers is the aggregate of all reality checkers, providing a single entry point for callers to access the current state of the cluster, machines, and block node.

func NewCheckers

func NewCheckers(sm state.Manager, opts ...CheckerOption) (Checkers, error)

NewCheckers constructs a Checker composed of three focused sub-checkers. Production defaults are applied; use CheckerOption to override for tests.

type ClusterProbe

type ClusterProbe func() (bool, error)

ClusterProbe abstracts the package-level kube.ClusterExists check. Exported so callers can provide fakes in tests.

type HelmManager

type HelmManager interface {
	ListAll() ([]*release.Release, error)
}

HelmManager is the subset of helm2.Manager used by the BlockNode checker. Swap in a fake for unit tests.

type KubeClient

type KubeClient interface {
	List(ctx context.Context, kind kube.ResourceKind, namespace string, opts kube.WaitOptions) (*unstructured.UnstructuredList, error)
}

KubeClient is the subset of kube.Client used by the BlockNode checker.

Jump to

Keyboard shortcuts

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