reality

package
v0.32.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 Checker

type Checker[T any] interface {
	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 NewConsensusChecker added in v0.31.0

func NewConsensusChecker(
	sm state.Manager,
	newKube func() (ConsensusKubeClient, error),
	clusterExists ClusterProbe,
) (Checker[map[string]state.ConsensusNodeState], error)

NewConsensusChecker creates a reality checker that reads Orbit and ConsensusCapsule CRs from the cluster to build a map of ConsensusNodeState.

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.

func NewTeleportChecker added in v0.16.0

func NewTeleportChecker(
	sm state.Manager,
	newHelm func() (HelmManager, error),
	clusterExists ClusterProbe,
) (Checker[state.TeleportState], error)

NewTeleportChecker constructs a teleportChecker.

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]
	Consensus Checker[map[string]state.ConsensusNodeState]
	Teleport  Checker[state.TeleportState]
}

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 ConsensusKubeClient added in v0.31.0

type ConsensusKubeClient interface {
	ResourceExists(ctx context.Context, apiVersion, kind, namespace, name string) (bool, error)
	GetResourceNestedString(ctx context.Context, apiVersion, kind, namespace, name string, fields ...string) (string, error)
	GetResourceNestedInt64(ctx context.Context, apiVersion, kind, namespace, name string, fields ...string) (int64, bool, error)
}

ConsensusKubeClient is the subset of kube.Client used by the consensus checker.

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