executor

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024-2025 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResizeWindowHandler added in v0.7.0

func ResizeWindowHandler(sigs chan os.Signal, stdin *os.File, session *SshCSession)

Types

type SshCEmitter

type SshCEmitter struct {
	HostWriterStdout io.WriteCloser
	HostWriterStderr io.WriteCloser
	SshWriterStdout  io.WriteCloser
	SshWriterStderr  io.WriteCloser
}

func NewSshCEmitter

func NewSshCEmitter() *SshCEmitter

func (*SshCEmitter) DebugLog

func (e *SshCEmitter) DebugLog(color bool, args ...interface{})

func (*SshCEmitter) Emits

func (e *SshCEmitter) Emits(eType SshCExecutorEvent, data map[string]interface{})

func (*SshCEmitter) ErrorLog

func (e *SshCEmitter) ErrorLog(color bool, args ...interface{})

func (*SshCEmitter) GetHostWriterStderr

func (e *SshCEmitter) GetHostWriterStderr() io.WriteCloser

func (*SshCEmitter) GetHostWriterStdout

func (e *SshCEmitter) GetHostWriterStdout() io.WriteCloser

func (*SshCEmitter) GetSshWriterStderr

func (e *SshCEmitter) GetSshWriterStderr() io.WriteCloser

func (*SshCEmitter) GetSshWriterStdout

func (e *SshCEmitter) GetSshWriterStdout() io.WriteCloser

func (*SshCEmitter) InfoLog

func (e *SshCEmitter) InfoLog(color bool, args ...interface{})

func (*SshCEmitter) SetHostWriterStderr

func (e *SshCEmitter) SetHostWriterStderr(w io.WriteCloser)

func (*SshCEmitter) SetHostWriterStdout

func (e *SshCEmitter) SetHostWriterStdout(w io.WriteCloser)

func (*SshCEmitter) SetSshWriterStderr

func (e *SshCEmitter) SetSshWriterStderr(w io.WriteCloser)

func (*SshCEmitter) SetSshWriterStdout

func (e *SshCEmitter) SetSshWriterStdout(w io.WriteCloser)

func (*SshCEmitter) WarnLog

func (e *SshCEmitter) WarnLog(color bool, args ...interface{})

type SshCEmitterWriter

type SshCEmitterWriter struct {
	Type string
}

func NewSshCEmitterWriter

func NewSshCEmitterWriter(t string) *SshCEmitterWriter

func (*SshCEmitterWriter) Close

func (e *SshCEmitterWriter) Close() error

func (*SshCEmitterWriter) Write

func (e *SshCEmitterWriter) Write(p []byte) (int, error)

type SshCExecutor

type SshCExecutor struct {
	Endpoint string
	Host     string
	// Ssh connection protocol. Valid values: tcp,tcp4,tcp6,unix
	ConnProtocol      string
	Port              int
	TimeoutSecs       *uint
	ShowCmdsOutput    bool
	RuntimeCmdsOutput bool
	Entrypoint        []string

	TTYOpISpeed uint32
	TTYOpOSpeed uint32

	User           string
	Pass           string
	PrivateKey     string
	PrivateKeyPass string

	Client     *ssh.Client
	SftpClient *sftp.Client

	Sessions map[string]*SshCSession

	Emitter SshCExecutorEmitter

	// ConfigDir of SSHC_CONF
	ConfigDir string

	// Context used to manage all SSL sessions
	Ctx    context.Context
	Cancel context.CancelFunc

	TunnelChain     []*TunnelHop
	TunnelLocalPort int
	TunnelLocalAddr string
	TunnelLocalBind bool
	LocalListener   net.Listener
	LocalListenerWg sync.WaitGroup
}

func NewSshCExecutor

func NewSshCExecutor(endpoint, host string, port int) *SshCExecutor

func NewSshCExecutorFromRemote

func NewSshCExecutorFromRemote(rname string, r *specs.Remote) (*SshCExecutor, error)

func (*SshCExecutor) BuildChain added in v0.7.0

func (s *SshCExecutor) BuildChain() (*ssh.Client, error)

func (*SshCExecutor) Close

func (s *SshCExecutor) Close()

func (*SshCExecutor) GetClient

func (s *SshCExecutor) GetClient() *ssh.Client

func (*SshCExecutor) GetConnProtocol

func (s *SshCExecutor) GetConnProtocol() string

func (*SshCExecutor) GetEmitter

func (e *SshCExecutor) GetEmitter() SshCExecutorEmitter

func (*SshCExecutor) GetEndpoint

func (s *SshCExecutor) GetEndpoint() string

func (*SshCExecutor) GetHost

func (s *SshCExecutor) GetHost() string

func (*SshCExecutor) GetPass

func (s *SshCExecutor) GetPass() string

func (*SshCExecutor) GetPort

func (s *SshCExecutor) GetPort() int

func (*SshCExecutor) GetPrivateKey

func (s *SshCExecutor) GetPrivateKey() string

func (*SshCExecutor) GetPrivateKeyPass

func (s *SshCExecutor) GetPrivateKeyPass() string

func (*SshCExecutor) GetRuntimeCmdsOutput

func (s *SshCExecutor) GetRuntimeCmdsOutput() bool

func (*SshCExecutor) GetSession

func (s *SshCExecutor) GetSession(n string) (*SshCSession, error)

func (*SshCExecutor) GetSftpClient

func (s *SshCExecutor) GetSftpClient() *sftp.Client

func (*SshCExecutor) GetShellSession

func (s *SshCExecutor) GetShellSession(n, termType string, h, w int, echo bool) (*SshCSession, error)

func (*SshCExecutor) GetShellSessionWithTermSetup

func (s *SshCExecutor) GetShellSessionWithTermSetup(n, termType string,
	stdin *os.File, stdout, stderr io.Writer) (*SshCSession, TermShellRestoreCb, error)

func (*SshCExecutor) GetShowCmdsOutput

func (s *SshCExecutor) GetShowCmdsOutput() bool

func (*SshCExecutor) GetUser

func (s *SshCExecutor) GetUser() string

func (*SshCExecutor) RecursiveMkdir

func (s *SshCExecutor) RecursiveMkdir(dir string, mode *os.FileMode, uid int, gid int, ensurePerms bool) error

func (*SshCExecutor) RecursivePullFile

func (s *SshCExecutor) RecursivePullFile(nodeName, sourcePath, targetPath string, localAsTarget, ensurePerms bool) error

func (*SshCExecutor) RecursivePushFile

func (s *SshCExecutor) RecursivePushFile(nodeName, source, target string, ensurePerms bool) error

func (*SshCExecutor) RemoveSession

func (s *SshCExecutor) RemoveSession(n string) error

func (*SshCExecutor) ResetSession

func (s *SshCExecutor) ResetSession(n string) (*SshCSession, error)

func (*SshCExecutor) RunCommand

func (e *SshCExecutor) RunCommand(nodeName, command string, envs map[string]string, entryPoint []string) (int, error)

func (*SshCExecutor) RunCommandWithOutput

func (e *SshCExecutor) RunCommandWithOutput(nodeName, command string, envs map[string]string, outBuffer, errBuffer io.WriteCloser, entryPoint []string) (int, error)

func (*SshCExecutor) RunCommandWithOutput4Var

func (e *SshCExecutor) RunCommandWithOutput4Var(nodeName, command, outVar, errVar string, envs *map[string]string, entryPoint []string) (int, error)

func (*SshCExecutor) RunHostCommand

func (e *SshCExecutor) RunHostCommand(command string, envs map[string]string, entryPoint []string) (int, error)

func (*SshCExecutor) RunHostCommandWithOutput

func (e *SshCExecutor) RunHostCommandWithOutput(command string, envs map[string]string, outBuffer, errBuffer io.WriteCloser, entryPoint []string) (int, error)

func (*SshCExecutor) RunHostCommandWithOutput4Var

func (e *SshCExecutor) RunHostCommandWithOutput4Var(command, outVar, errVar string, envs *map[string]string, entryPoint []string) (int, error)

func (*SshCExecutor) SetEmitter

func (e *SshCExecutor) SetEmitter(emitter SshCExecutorEmitter)

func (*SshCExecutor) Setup

func (s *SshCExecutor) Setup() error

func (*SshCExecutor) SetupSftp

func (s *SshCExecutor) SetupSftp(opts ...sftp.ClientOption) error

type SshCExecutorEmitter

type SshCExecutorEmitter interface {
	Emits(eType SshCExecutorEvent, data map[string]interface{})

	DebugLog(color bool, args ...interface{})
	InfoLog(color bool, args ...interface{})
	WarnLog(color bool, args ...interface{})
	ErrorLog(color bool, args ...interface{})
}

type SshCExecutorEvent

type SshCExecutorEvent string
const (
	SshClientSetupDone    SshCExecutorEvent = "client-setup"
	SshContainerConnected SshCExecutorEvent = "endpoint-connected"
)

type SshCSession

type SshCSession struct {
	*ssh.Session
	Name string
}

func NewSshCSession

func NewSshCSession(name string, s *ssh.Session) *SshCSession

func (*SshCSession) GetName

func (s *SshCSession) GetName() string

func (*SshCSession) GetRawSession

func (s *SshCSession) GetRawSession() *ssh.Session

type TermShellRestoreCb

type TermShellRestoreCb func() error

type TunnelHop added in v0.7.0

type TunnelHop struct {
	// Ssh connection protocol. Valid values: tcp,tcp4,tcp6,unix
	ConnProtocol string
	Host         string
	Port         int
	TimeoutSecs  *uint

	User           string
	Pass           string
	PrivateKey     string
	PrivateKeyPass string

	Client *ssh.Client
}

func NewTunnelHop added in v0.7.0

func NewTunnelHop(r *specs.Remote) (*TunnelHop, error)

Jump to

Keyboard shortcuts

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