dutssh

package
v0.0.0-...-19f3ddf Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudbotsDutProxyClient

func CloudbotsDutProxyClient(ctx context.Context, dutName string) (*ssh.Client, error)

CloudbotsDutProxyClient returns the ssh connection from cloudbots to dut.

func GetSSHAddr

func GetSSHAddr(ctx context.Context, name string, wiringAddress string) (string, error)

GetSSHAddr returns the SSH address to use for the DUT, through the wiring service.

func GetSSHConfig

func GetSSHConfig() *ssh.ClientConfig

GetSSHConfig construct a static ssh config

func PathExistsCommand

func PathExistsCommand(path string) string

func RunSerializerCommand

func RunSerializerCommand(path string, chunkSize int64, fetchCore bool) string

Types

type ClientInterface

type ClientInterface interface {
	Close() error
	NewSession() (SessionInterface, error)
	Wait() error
	IsAlive() bool
}

This file only exists because go cannot mock structs and the ssh client library does not provide interfaces for testing.

type CmdExecutor

type CmdExecutor interface {
	RunCmd(cmd string) (*CmdResult, error)
}

Simple interface abstracting away many details around SSH/streaming for clients that execute many simple/quick commands. This insulate clients from the full complexity of DutServer and also makes it easier to test logic that's focused on command execution results. E.g. Identity scanning

type CmdResult

type CmdResult struct {
	ReturnCode int32
	StdOut     string
	StdErr     string
}

type SSHClient

type SSHClient struct {
	*ssh.Client
}

func (*SSHClient) Close

func (c *SSHClient) Close() error

func (*SSHClient) IsAlive

func (c *SSHClient) IsAlive() bool

func (*SSHClient) NewSession

func (c *SSHClient) NewSession() (SessionInterface, error)

func (*SSHClient) Wait

func (c *SSHClient) Wait() error

type SSHSession

type SSHSession struct {
	*ssh.Session
}

func (*SSHSession) Close

func (s *SSHSession) Close() error

func (*SSHSession) Output

func (s *SSHSession) Output(cmd string) ([]byte, error)

func (*SSHSession) Run

func (s *SSHSession) Run(cmd string) error

func (*SSHSession) SetStderr

func (s *SSHSession) SetStderr(writer io.Writer)

func (*SSHSession) SetStdin

func (s *SSHSession) SetStdin(reader io.Reader)

func (*SSHSession) SetStdout

func (s *SSHSession) SetStdout(writer io.Writer)

func (*SSHSession) Start

func (s *SSHSession) Start(cmd string) error

func (*SSHSession) StderrPipe

func (s *SSHSession) StderrPipe() (io.Reader, error)

func (*SSHSession) StdoutPipe

func (s *SSHSession) StdoutPipe() (io.Reader, error)

type SessionInterface

type SessionInterface interface {
	Close() error
	SetStdout(writer io.Writer)
	SetStderr(writer io.Writer)
	SetStdin(reader io.Reader)
	Run(cmd string) error
	Start(cmd string) error
	Output(cmd string) ([]byte, error)
	StdoutPipe() (io.Reader, error)
	StderrPipe() (io.Reader, error)
}

Directories

Path Synopsis
Package mock_dutssh is a generated GoMock package.
Package mock_dutssh is a generated GoMock package.

Jump to

Keyboard shortcuts

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