Documentation
¶
Index ¶
- Constants
- func DebugLog(format string, args ...any)
- func DisableSleepForTest() (restore func())
- func Env(key, fallback string) string
- func EnvBool(key string, fallback bool) bool
- func EnvInt(key string, fallback int) int
- func EnvRaw(key, fallback string) string
- func ErrorLog(format string, args ...any)
- func FatalLog(format string, args ...any)
- func InfoLog(format string, args ...any)
- func InitLogging(jsonMode bool)
- func Ptr[T any](v T) *T
- func RegisterSecret(value string)
- func SetSleepForTest(fn func(time.Duration)) (restore func())
- func Sleep(d time.Duration)
- func WarnLog(format string, args ...any)
- type Config
- type EventSink
- type NopEventSink
Constants ¶
const ( // DefaultDeleteTimeout bounds pod-termination / PVC-detach waits. DefaultDeleteTimeout = 300 // DefaultHealTimeout bounds a node heal / cluster-rejoin wait. DefaultHealTimeout = 600 )
Default operation timeouts, in seconds, used when the config leaves them unset.
const EnvPrefix = "HASTEWARD_"
Variables ¶
This section is empty.
Functions ¶
func DisableSleepForTest ¶ added in v0.2.0
func DisableSleepForTest() (restore func())
DisableSleepForTest makes Sleep a no-op (poll loops run instantly) and returns a restore func. TEST-ONLY.
func EnvBool ¶
EnvBool reads HASTEWARD_<KEY> as a boolean. Accepts "1", "t", "true", "yes", "on" (case-insensitive).
func EnvRaw ¶
EnvRaw reads a raw environment variable (no prefix) with a fallback default. Used for standard env vars like KUBECONFIG that don't use the HASTEWARD_ prefix.
func InitLogging ¶
func InitLogging(jsonMode bool)
InitLogging sets up the slog-based logging system. jsonMode=true uses JSONHandler (for serve mode), false uses TextHandler (for CLI).
func Ptr ¶ added in v0.2.0
func Ptr[T any](v T) *T
Ptr returns a pointer to v — handy for the many optional/pointer fields in the Kubernetes API types (GracePeriodSeconds, Replicas, …).
func RegisterSecret ¶
func RegisterSecret(value string)
RegisterSecret adds a value to be redacted from all log output.
func SetSleepForTest ¶ added in v0.2.0
SetSleepForTest replaces Sleep and returns a restore func. TEST-ONLY.
Types ¶
type Config ¶
type Config struct {
Engine string
ClusterName string
Namespace string
Mode string
InstanceNumber *int
DonorInstance *int // Explicit donor ordinal for forced repair (declares authoritative source)
Force bool
WipeDatadir bool // Wipe entire datadir (not just grastate) — forces full SST reseed from donor
FixBootstrap bool // Reconfigure: clear grastate + remove bootstrap config on target instance
BackupsPath string
NoEscrow bool
Unwedge bool // --unwedge: enable the CNPG disk-full deadlock breaker (escrow-gated offline datadir clear)
BackupMethod string
Snapshot string // Restic snapshot ID or "latest" (for restore)
ResticPassword string // Restic repository encryption password
HealTimeout int
DeleteTimeout int
Kubeconfig string
Verbose bool
DryRun bool // preview destructive actions without executing (set from --dry-run)
}
Config holds all runtime configuration for a hasteward run.
type EventSink ¶
type EventSink interface {
Info(msg string, fields ...any)
Warn(msg string, fields ...any)
Progress(operation string, current, total int64)
Step(name string, status string)
}
EventSink receives progress events from engine operations. Implementations format these for CLI output, slog, metrics, etc.
type NopEventSink ¶
type NopEventSink struct{}
NopEventSink discards all events.
func (NopEventSink) Info ¶
func (NopEventSink) Info(string, ...any)
func (NopEventSink) Step ¶
func (NopEventSink) Step(string, string)
func (NopEventSink) Warn ¶
func (NopEventSink) Warn(string, ...any)