wissh

package
v0.0.0-...-74dca4c Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check interface {
	// Name returns a user-friendly name for the check. This is meant to be
	// displayed in the UI to identify the check and should give the user an
	// idea of what it does.
	Name() string

	// Run runs the test. The return value tells if there was some error while
	// running the Check, not if the check has passed.
	//
	// A Check can assume that Run will be the first of its methods to be
	// called. Furthermore, if the error is not nil, it can assume the other
	// methods will not be called.
	Run() error

	// Passed checks if the test passed.
	Passed() bool

	// IlluminatingRemarks returns any remarks that may illuminate the user.
	// Because here we are not satisfied with simple feedback: we explain why
	// things are failing, how balena works, what the user could try to do to
	// solve the issue, and, when appropriate, help with transcendence.
	//
	// The first return value tells if the check actually has remarks. The
	// second one contains the remarks themselves, as a Markdown string.
	IlluminatingRemarks() (bool, string)

	// Details returns details about the execution of the check. This should
	// include all the low-level details a more advanced user could make good
	// use of.
	//
	// The first return value tells if the check actually has details. The
	// second one contains the details themselves, as a Markdown string.
	Details() (bool, string)
}

Check defines how any of the tests we can run looks like.

type SSHCommand

type SSHCommand struct {
	// The IP address of the device in which we'll run the SSH command. Must be
	// set before calling Run.
	IP string

	// The port to which we'll connect to run the SSH command. Must be set
	// before calling Run.
	Port string

	// The path to the file with the private key to use when authenticating with
	// the device. Must be set before calling Run.
	//
	// TODO: This is required for now, and must point to a valid file. This
	// doesn't prevent us from connecting to devices in development mode (which
	// don't need authentication by default), but is kinda odd. Should be
	// optional.
	SSHKeyFile string

	// Command contains the command to run over SSH. Must be set before calling
	// Run.
	Command string

	// ExitStatus contains the exit status code of the SSH command. This is set
	// by Run.
	ExitStatus int

	// StdOut contains the standard output of the SSH command. This is set by
	// Run.
	StdOut string

	// StdErr contains the standard error of the SSH command. This is set by
	// Run.
	StdErr string
}

SSHCommand provides some boilerplate for implementing a Check that works by running a SSH command on the device.

func (*SSHCommand) Details

func (c *SSHCommand) Details() (bool, string)

func (*SSHCommand) Run

func (c *SSHCommand) Run() error

type SSHRunner

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

SSHRunner allows to run SSH commands. Technically, it's a wrapper around Go's ssh.Client.

func NewSSHRunner

func NewSSHRunner(user, addr, keyFile string) (*SSHRunner, error)

NewSSHRunner creates a new SSHRunner. It will try to start an SSH session by user, on a server located at addr, and autheticating using the key at keyFile. Note that addr shall include the port, like "10.0.0.1:22222").

You must call Destroy() on the returned SSHRunner when it is no longer needed.

func (*SSHRunner) Destroy

func (s *SSHRunner) Destroy()

Destroy frees all resources used by the Runner.

func (*SSHRunner) Run

func (s *SSHRunner) Run(cmd string) (stdOut string, stdErr string, err error)

Run runs the cmd command over SSH.

Jump to

Keyboard shortcuts

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