utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout = errors.New("Timeout step running")
)

Functions

func CheckSSHHosts

func CheckSSHHosts(userPassedHosts []session.Host, nodesNames []string, phase string, runConfirm func(string) bool) (map[string]string, error)

func ExecuteRemoteScriptPath

func ExecuteRemoteScriptPath(u ScriptPath, scriptName string, full bool) string

ExecuteRemoteScriptPath deprecated - ugly solution

func ParseSSHPrivateKey

func ParseSSHPrivateKey(keyData []byte, keyName string, passphraseConsumer PassphraseConsumer) (any, string, error)

func ParseSSHPrivateKeyFile

func ParseSSHPrivateKeyFile(path string, password string, logger log.Logger) (any, string, error)

func SafeClose

func SafeClose(conn io.Closer, presentHandlers ...PresentCloseHandler) error

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 NewBundle

func NewBundle(sett settings.Settings, client connection.SSHClient, scriptPath string, args []string, opts ...BundleOpt) (*Bundle, error)

func (*Bundle) Execute

func (b *Bundle) Execute(ctx context.Context, parentDir, bundleDir string) ([]byte, error)

type BundleOpt

type BundleOpt func(*Bundle)

func BundleWithCommandKiller

func BundleWithCommandKiller(k CommandKiller) BundleOpt

func BundleWithCommandPreparator

func BundleWithCommandPreparator(p CommandPreparator) BundleOpt

func BundleWithNoLogStepOutOnError

func BundleWithNoLogStepOutOnError(v bool) BundleOpt

func BundleWithRetries

func BundleWithRetries(r int) BundleOpt

func BundleWithStepHeader

func BundleWithStepHeader(r *regexp.Regexp) BundleOpt

func BundleWithStepsDelimiter

func BundleWithStepsDelimiter(d string) BundleOpt

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 Check

type Check struct {
	Session *session.Session
	// contains filtered or unexported fields
}

func NewCheck

func NewCheck(createCommand CommandConsumer, sess *session.Session, sett settings.Settings) *Check

func (*Check) AwaitAvailability

func (c *Check) AwaitAvailability(ctx context.Context, loopParams retry.Params) error

func (*Check) CheckAvailability

func (c *Check) CheckAvailability(ctx context.Context) error

func (*Check) ExpectAvailable

func (c *Check) ExpectAvailable(ctx context.Context) ([]byte, error)

func (*Check) String

func (c *Check) String() string

func (*Check) WithDelaySeconds

func (c *Check) WithDelaySeconds(seconds int) ssh.Check

type CommandConsumer

type CommandConsumer func(*session.Session, string) ssh.Command

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

type PassphraseConsumer

type PassphraseConsumer interface {
	DefaultPassword() []byte
	AskPassword(prompt string) ([]byte, error)
}

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

type ScriptPath

type ScriptPath interface {
	IsSudo() bool
	UploadDir() string
	Settings() settings.Settings
}

type TerminalPassphraseConsumer

type TerminalPassphraseConsumer struct {
	// contains filtered or unexported fields
}

func NewTerminalPassphraseConsumer

func NewTerminalPassphraseConsumer(logger log.Logger, defaultPassword []byte) *TerminalPassphraseConsumer

func (*TerminalPassphraseConsumer) AskPassword

func (c *TerminalPassphraseConsumer) AskPassword(prompt string) ([]byte, error)

func (TerminalPassphraseConsumer) DefaultPassword

func (c TerminalPassphraseConsumer) DefaultPassword() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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