state

package
v5.99.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package state provides cluster state persistence for distributions that cannot introspect their running configuration (Kind, K3d).

State is stored as JSON in ~/.ksail/clusters/<name>/spec.json so that the update command can compare the desired configuration against the actual configuration used at creation time, avoiding false-positive diffs.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidClusterName = errors.New(
	"invalid cluster name: must not contain path separators or '..'",
)

ErrInvalidClusterName is returned when a cluster name contains path traversal characters.

View Source
var ErrNonPositiveTTL = errors.New("TTL duration must be positive")

ErrNonPositiveTTL is returned when a non-positive TTL duration is provided.

View Source
var ErrStateNotFound = errors.New("cluster state not found")

ErrStateNotFound is returned when no saved state exists for a cluster.

View Source
var ErrTTLNotSet = errors.New("cluster TTL not set")

ErrTTLNotSet is returned when no TTL has been set for a cluster.

Functions

func DeleteClusterState

func DeleteClusterState(clusterName string) error

DeleteClusterState removes the saved state for a cluster. This should be called during cluster deletion to clean up. Returns nil if the state does not exist (idempotent).

func LoadClusterSpec

func LoadClusterSpec(clusterName string) (*v1alpha1.ClusterSpec, error)

LoadClusterSpec loads a previously saved ClusterSpec for a cluster. Returns ErrStateNotFound if no state exists for this cluster name.

func SaveClusterSpec

func SaveClusterSpec(clusterName string, spec *v1alpha1.ClusterSpec) error

SaveClusterSpec persists the ClusterSpec used during cluster creation. This allows the update command to compare against the actual creation-time configuration instead of static defaults.

func SaveClusterTTL added in v5.55.0

func SaveClusterTTL(clusterName string, ttl time.Duration) error

SaveClusterTTL persists TTL information for a cluster. ttl must be a positive duration. Returns ErrNonPositiveTTL otherwise. The expiry time is calculated as now + ttl.

Types

type TTLInfo added in v5.55.0

type TTLInfo struct {
	// ExpiresAt is the UTC time when the cluster should be destroyed.
	ExpiresAt time.Time `json:"expiresAt"`
	// Duration is the normalized string representation of the TTL (e.g. "2h0m0s").
	Duration string `json:"duration"`
}

TTLInfo holds time-to-live information for a cluster.

func LoadClusterTTL added in v5.55.0

func LoadClusterTTL(clusterName string) (*TTLInfo, error)

LoadClusterTTL loads TTL information for a cluster. Returns ErrTTLNotSet if no TTL has been set for the cluster.

func (*TTLInfo) IsExpired added in v5.55.0

func (t *TTLInfo) IsExpired() bool

IsExpired reports whether the cluster TTL has passed.

func (*TTLInfo) Remaining added in v5.55.0

func (t *TTLInfo) Remaining() time.Duration

Remaining returns the duration remaining until TTL expiry. Returns a non-positive duration if the TTL has already expired.

Jump to

Keyboard shortcuts

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