Documentation
¶
Index ¶
- Constants
- Variables
- func BashibleBundleOpts() []connection.BundlerOption
- func CheckSSHHosts(userPassedHosts []session.Host, nodesNames []string, phase string, ...) (map[string]string, error)
- func ExecuteRemoteScriptPath(u ScriptPath, scriptName string, full bool) string
- func ParseSSHPrivateKey(ctx context.Context, keyData []byte, keyName string, ...) (any, string, error)
- func ParseSSHPrivateKeyFile(ctx context.Context, path string, password string, logger *slog.Logger) (any, string, error)
- func SafeClose(conn io.Closer, presentHandlers ...PresentCloseHandler) error
- type BaseReverseTunnelRoutines
- type Bundle
- type BundleCmdProvider
- type BundleOpt
- func BundleWithCommandKiller(k CommandKiller) BundleOpt
- func BundleWithCommandPreparator(p CommandPreparator) BundleOpt
- func BundleWithNoLogStepOutOnError(v bool) BundleOpt
- func BundleWithRetries(r int) BundleOpt
- func BundleWithShouldInfoOutChecker(c connection.BundlerShouldInfoOutChecker) BundleOpt
- func BundleWithStepHeader(r *regexp.Regexp) BundleOpt
- func BundleWithStepsDelimiter(d string) BundleOpt
- func UserBundleOptsOrBashible(inputOpts ...connection.BundlerOption) ([]BundleOpt, error)
- type ByteSequenceMatcher
- type Check
- func (c *Check) AwaitAvailability(ctx context.Context, loopParams retry.Params) error
- func (c *Check) CheckAvailability(ctx context.Context) error
- func (c *Check) ExpectAvailable(ctx context.Context) ([]byte, error)
- func (c *Check) String() string
- func (c *Check) WithDelaySeconds(seconds int) ssh.Check
- type CommandConsumer
- type CommandKiller
- type CommandPreparator
- type DefaultPassphraseOnlyConsumer
- type EmptyReverseTunnelKiller
- type PassphraseConsumer
- type PresentCloseHandler
- type RunScriptReverseTunnelChecker
- type RunScriptReverseTunnelKiller
- type ScriptPath
- type TerminalPassphraseConsumer
- type TunnelBackend
- type TunnelSupervisor
Constants ¶
const MaxConsecutiveTunnelRestarts = 1024
MaxConsecutiveTunnelRestarts guards against a tunnel that can never come back up: better to crash loudly than to spin forever.
Variables ¶
var (
ErrBundleTimeout = errors.New("Timeout step running")
)
Functions ¶
func BashibleBundleOpts ¶ added in v0.7.0
func BashibleBundleOpts() []connection.BundlerOption
func CheckSSHHosts ¶
func ExecuteRemoteScriptPath ¶
func ExecuteRemoteScriptPath(u ScriptPath, scriptName string, full bool) string
ExecuteRemoteScriptPath deprecated - ugly solution
func ParseSSHPrivateKey ¶
func ParseSSHPrivateKeyFile ¶
Types ¶
type BaseReverseTunnelRoutines ¶
type BaseReverseTunnelRoutines[T any] struct { // contains filtered or unexported fields }
func (*BaseReverseTunnelRoutines[T]) SetUploadDirAndCleanup ¶
func (b *BaseReverseTunnelRoutines[T]) SetUploadDirAndCleanup(dir string) *T
func (*BaseReverseTunnelRoutines[T]) WithCleanup ¶
func (b *BaseReverseTunnelRoutines[T]) WithCleanup() *T
func (*BaseReverseTunnelRoutines[T]) WithUploadDir ¶
func (b *BaseReverseTunnelRoutines[T]) WithUploadDir(dir string) *T
type Bundle ¶
type Bundle struct {
// contains filtered or unexported fields
}
func (*Bundle) WithCmdProvider ¶ added in v0.7.0
func (b *Bundle) WithCmdProvider(provider BundleCmdProvider) *Bundle
type BundleCmdProvider ¶ added in v0.7.0
type BundleCmdProvider func(ctx context.Context, node connection.Interface, parentDir, bundleDir string) (connection.Command, error)
type BundleOpt ¶
type BundleOpt func(*Bundle)
func BundleWithCommandKiller ¶
func BundleWithCommandKiller(k CommandKiller) BundleOpt
func BundleWithCommandPreparator ¶
func BundleWithCommandPreparator(p CommandPreparator) BundleOpt
func BundleWithRetries ¶
func BundleWithShouldInfoOutChecker ¶ added in v0.7.0
func BundleWithShouldInfoOutChecker(c connection.BundlerShouldInfoOutChecker) BundleOpt
func BundleWithStepHeader ¶
func UserBundleOptsOrBashible ¶
func UserBundleOptsOrBashible(inputOpts ...connection.BundlerOption) ([]BundleOpt, error)
type ByteSequenceMatcher ¶
type ByteSequenceMatcher struct {
// settings
Pattern string
// contains filtered or unexported fields
}
ByteSequenceMatcher can be used to match byte stream against a string byte by byte.
func NewByteSequenceMatcher ¶
func NewByteSequenceMatcher(pattern string) *ByteSequenceMatcher
func (*ByteSequenceMatcher) Analyze ¶
func (m *ByteSequenceMatcher) Analyze(buf []byte) int
Analyze matches Pattern from byte stream and ignores \r and \n after it. when match is not found, return n when match is found, return 0 return index (0 or more) of a first byte after pattern and \r, \n This behaviour is used to write bytes to Reader only after match is found.
func (*ByteSequenceMatcher) IsMatched ¶
func (m *ByteSequenceMatcher) IsMatched() bool
func (*ByteSequenceMatcher) Reset ¶
func (m *ByteSequenceMatcher) Reset()
func (*ByteSequenceMatcher) WaitNonMatched ¶
func (m *ByteSequenceMatcher) WaitNonMatched() *ByteSequenceMatcher
type CommandKiller ¶
type CommandKiller func(connection.Command)
type CommandPreparator ¶
type CommandPreparator func(connection.Command)
type DefaultPassphraseOnlyConsumer ¶
type DefaultPassphraseOnlyConsumer struct {
// contains filtered or unexported fields
}
func NewDefaultPassphraseOnlyConsumer ¶
func NewDefaultPassphraseOnlyConsumer(defaultPassword string) *DefaultPassphraseOnlyConsumer
func (*DefaultPassphraseOnlyConsumer) AskPassword ¶
func (c *DefaultPassphraseOnlyConsumer) AskPassword(prompt string) ([]byte, error)
func (DefaultPassphraseOnlyConsumer) DefaultPassword ¶
func (c DefaultPassphraseOnlyConsumer) DefaultPassword() []byte
type EmptyReverseTunnelKiller ¶
type EmptyReverseTunnelKiller struct{}
func (EmptyReverseTunnelKiller) KillTunnel ¶
func (k EmptyReverseTunnelKiller) KillTunnel(context.Context) (string, error)
type PassphraseConsumer ¶
type PresentCloseHandler ¶
type PresentCloseHandler func(isPresent bool)
type RunScriptReverseTunnelChecker ¶
type RunScriptReverseTunnelChecker struct {
*BaseReverseTunnelRoutines[RunScriptReverseTunnelChecker]
// contains filtered or unexported fields
}
func NewRunScriptReverseTunnelChecker ¶
func NewRunScriptReverseTunnelChecker(c ssh.SSHClient, scriptPath string) *RunScriptReverseTunnelChecker
func (*RunScriptReverseTunnelChecker) CheckTunnel ¶
func (s *RunScriptReverseTunnelChecker) CheckTunnel(ctx context.Context) (string, error)
type RunScriptReverseTunnelKiller ¶
type RunScriptReverseTunnelKiller struct {
*BaseReverseTunnelRoutines[RunScriptReverseTunnelKiller]
// contains filtered or unexported fields
}
func NewRunScriptReverseTunnelKiller ¶
func NewRunScriptReverseTunnelKiller(c ssh.SSHClient, scriptPath string) *RunScriptReverseTunnelKiller
func (*RunScriptReverseTunnelKiller) KillTunnel ¶
func (s *RunScriptReverseTunnelKiller) KillTunnel(ctx context.Context) (string, error)
type ScriptPath ¶
type TerminalPassphraseConsumer ¶
type TerminalPassphraseConsumer struct {
// contains filtered or unexported fields
}
func NewTerminalPassphraseConsumer ¶
func NewTerminalPassphraseConsumer(logger *slog.Logger, defaultPassword []byte) *TerminalPassphraseConsumer
func (*TerminalPassphraseConsumer) AskPassword ¶
func (TerminalPassphraseConsumer) DefaultPassword ¶
func (c TerminalPassphraseConsumer) DefaultPassword() []byte
type TunnelBackend ¶ added in v0.11.0
type TunnelBackend interface {
// StartTunnel brings a tunnel instance up. Implementations must refuse to
// start (return an error) once ctx is canceled — this is what guarantees
// nothing is brought up behind a Stop.
StartTunnel(ctx context.Context) error
// StopTunnel tears the current tunnel instance down. Must be idempotent
// and must not block on the supervisor making progress.
StopTunnel()
// TunnelDone returns the termination channel of the current instance, or
// nil when nothing is up. The channel reports the instance's exit at most
// once and must never block the sender (i.e. it is buffered); it stays
// valid after the instance dies.
TunnelDone() <-chan error
// CheckTunnel probes the tunnel end-to-end, honoring ctx. True = healthy.
// Retry policy lives in the implementation; it also paces the supervision
// loop, so a CheckTunnel that fails instantly produces a hot restart loop —
// keep at least one retry/wait inside.
CheckTunnel(ctx context.Context) bool
}
TunnelBackend is the transport-specific part of a reverse tunnel: how to bring one instance up, how to tear it down, and how its termination is observed.
type TunnelSupervisor ¶ added in v0.11.0
type TunnelSupervisor struct {
// contains filtered or unexported fields
}
TunnelSupervisor keeps a reverse tunnel alive: it is the only actor that restarts tunnel instances, and its whole lifecycle is driven by context cancellation, which never blocks.
This replaces a previous per-implementation monitor that signaled stop over an unbuffered channel while holding the tunnel mutex — the monitor could simultaneously need that mutex to make progress, deadlocking the caller's teardown (observed live as a dhctl bootstrap hang in tomb.WaitShutdown).
func NewTunnelSupervisor ¶ added in v0.11.0
func NewTunnelSupervisor(backend TunnelBackend, killer connection.ReverseTunnelKiller, logger *slog.Logger) *TunnelSupervisor
func (*TunnelSupervisor) Start ¶ added in v0.11.0
func (s *TunnelSupervisor) Start(ctx context.Context)
Start launches the supervision loop. A previous loop, if any, is fully stopped first, so at most one loop ever supervises the backend.
func (*TunnelSupervisor) Stop ¶ added in v0.11.0
func (s *TunnelSupervisor) Stop()
Stop cancels the supervision loop and waits until it has fully unwound. The lock is NOT held across the wait: cancellation is the only signal, and the loop itself never takes this lock. Stop does not touch the tunnel — that is the owner's job (backend.StopTunnel after Stop returns).