driver

package
v0.0.0-...-d65772c Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command func(string) (string, error)

Command represents the two commands ReadFile & RunCommand

type Driver

type Driver interface {
	ReadFile(path string) (string, error)
	RunCommand(command string) (string, error)
	// shows the driver details, not sure if we should be showing OS name
	GetDetails() (SystemDetails, error)
}

Driver : specification of functions to be defined by every Driver

func ToDriver

func ToDriver(conn config.Connection) Driver

type Local

type Local struct {
	EnvVars []string
	// contains filtered or unexported fields
}

Local : Driver for handling local executions

func (*Local) GetDetails

func (d *Local) GetDetails() (SystemDetails, error)

func (*Local) ReadFile

func (d *Local) ReadFile(path string) (string, error)

func (*Local) RunCommand

func (d *Local) RunCommand(command string) (string, error)

RunCommand : For simple commands without shell variables, pipes, e.t.c They can be passed directly. For complex commands e.g `echo something | awk $var`, turn into a file to be saved under ./shell/

type Request

type Request string

Request : use specified request methods for web

const (
	// POST : HTTP post
	POST Request = "POST"
	// GET : HTTP get
	GET Request = "GET"
)

type SSH

type SSH struct {

	// User e.g root
	User string
	// Host name/ip e.g 171.23.122.1
	Host string
	// port default is 22
	Port int
	// Path to private key file
	KeyFile string
	// Pass key for key file
	KeyPass string
	// Password based login
	Password string
	// Check known hosts (only disable for tests
	CheckKnownHosts bool
	// set environmental vars for server e.g []string{"DEBUG=1", "FAKE=echo"}
	EnvVars       []string
	SessionClient *goph.Client
	// contains filtered or unexported fields
}

SSH : Driver for handling ssh executions

func (*SSH) Client

func (d *SSH) Client() (*goph.Client, error)

set the goph Client

func (*SSH) GetDetails

func (d *SSH) GetDetails() (SystemDetails, error)

func (*SSH) ReadFile

func (d *SSH) ReadFile(path string) (string, error)

func (*SSH) RunCommand

func (d *SSH) RunCommand(command string) (string, error)

func (*SSH) String

func (d *SSH) String() string

type SSHConnectError

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

func (*SSHConnectError) Error

func (e *SSHConnectError) Error() string

type SSHRunError

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

func (*SSHRunError) Error

func (e *SSHRunError) Error() string

type SystemDetails

type SystemDetails struct {
	IsWindows bool
	IsLinux   bool
	IsDarwin  bool
	IsWeb     bool
	Name      string
	Extra     string
}

SystemInfo gives more insight into system details

type Web

type Web struct {

	// URL e.g https://google.com
	URL string
	// Method POST/GET
	Method Request
	// Payload in case of a POST
	Payload string
	// contains filtered or unexported fields
}

Web : Driver for handling web executions

func (*Web) GetDetails

func (d *Web) GetDetails() (SystemDetails, error)

func (*Web) ReadFile

func (d *Web) ReadFile(path string) (string, error)

func (*Web) RunCommand

func (d *Web) RunCommand(command string) (string, error)

func (*Web) String

func (d *Web) String() string

Jump to

Keyboard shortcuts

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