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 ¶
var ErrInvalidClusterName = errors.New(
"invalid cluster name: must not contain path separators or '..'",
)
ErrInvalidClusterName is returned when a cluster name contains path traversal characters.
var ErrNonPositiveTTL = errors.New("TTL duration must be positive")
ErrNonPositiveTTL is returned when a non-positive TTL duration is provided.
var ErrStateNotFound = errors.New("cluster state not found")
ErrStateNotFound is returned when no saved state exists for a cluster.
var ErrTTLNotSet = errors.New("cluster TTL not set")
ErrTTLNotSet is returned when no TTL has been set for a cluster.
Functions ¶
func DeleteClusterState ¶
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.
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
LoadClusterTTL loads TTL information for a cluster. Returns ErrTTLNotSet if no TTL has been set for the cluster.