ssh

package
v0.0.0-...-f2f15b6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TMP_REMOTE_DIR = "/tmp/.machine"
)

Variables

View Source
var (
	ErrCopyNotRegular = errors.New("Can only copy regular file")
)

Functions

This section is empty.

Types

type Action

type Action struct {
	Cmd    string `yaml:"cmd,omitempty"`
	Script string `yaml:"script,omitempty"`
	Shell  bool   `yaml:"shell"`
	Sudo   bool   `yaml:"sudo"`
	Skip   bool   `yaml:"skip"`
}

func (Action) Act

func (a Action) Act(cmdr Commander) (output <-chan Response, err error)

func (Action) Command

func (a Action) Command() (cmd string)

type Archive

type Archive struct {
	Perhost bool   `yaml:"perhost"`
	Src     string `yaml:"src"`
	Dst     string `yaml:"dst"`
	Dir     string `yaml:"dir"`
	Sudo    bool   `yaml:"sudo"`
	Skip    bool   `yaml:"skip"`
}

func (Archive) Dest

func (a Archive) Dest() string

func (Archive) Send

func (a Archive) Send(cmdr Commander) error

func (Archive) Source

func (a Archive) Source(cmdr Commander) string

type Commander

type Commander interface {
	// Report host this Commander connects to
	Host() (host, port string)

	// Load file from target to here
	Load(target string, here io.Writer) error

	// Load file from target to here
	LoadFile(target, here string, mode os.FileMode) error

	// Copy file from src to dst
	Copy(src io.Reader, size int64, dst string, mode os.FileMode) error

	// Copy file from src to dst
	CopyFile(src, dst string, mode os.FileMode) error

	// Create full directory
	Mkdir(path string) error

	// Run command and retreive combinded output
	Run(cmd string) (string, error)

	// Run command and stay quiet
	RunQuiet(cmd string) error

	// Obtain a login shell
	Shell() error

	// Run command and stream combined output
	Stream(cmd string) (<-chan Response, error)

	// Elevate commander role and return a Deferr Target
	Sudo() SudoSession

	// Close Connection and cleanup
	Close() error
}

func New

func New(cfg Config) Commander

type Config

type Config struct {
	User     string
	Server   string
	Key      string
	Port     string
	Password string
}

func (Config) GetKeyFile

func (cfg Config) GetKeyFile() (ssh.Signer, error)

type Provision

type Provision struct {
	Archive []Archive `yaml:"archive,omitempty"`
	Name    string    `yaml:"name"`
	Ok2fail bool      `yaml:"ok2fail"`
	Action  []Action  `yaml:"action"`
	Skip    bool      `yaml:"skip"`
}

func (Provision) Clean

func (p Provision) Clean(cmdr Commander)

type Recipe

type Recipe struct {
	Archive   []Archive   `yaml:"archive,omitempty"`
	Provision []Provision `yaml:"provision"`
}

type Response

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

func (Response) Data

func (r Response) Data() (string, error)

type SSHCommander

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

func (*SSHCommander) Close

func (sshCmd *SSHCommander) Close() error

func (*SSHCommander) Copy

func (sshCmd *SSHCommander) Copy(src io.Reader, size int64, dst string, mode os.FileMode) error

func (*SSHCommander) CopyFile

func (sshCmd *SSHCommander) CopyFile(src, dst string, mode os.FileMode) error

func (*SSHCommander) Host

func (sshCmd *SSHCommander) Host() (host, port string)

func (*SSHCommander) Load

func (sshCmd *SSHCommander) Load(target string, here io.Writer) error

func (*SSHCommander) LoadFile

func (sshCmd *SSHCommander) LoadFile(target, here string, mode os.FileMode) error

func (*SSHCommander) Mkdir

func (sshCmd *SSHCommander) Mkdir(path string) error

func (*SSHCommander) Run

func (sshCmd *SSHCommander) Run(cmd string) (output string, err error)

func (*SSHCommander) RunQuiet

func (sshCmd *SSHCommander) RunQuiet(cmd string) (err error)

func (*SSHCommander) Shell

func (sshCmd *SSHCommander) Shell() (err error)

func (*SSHCommander) StepDown

func (sshCmd *SSHCommander) StepDown()

func (*SSHCommander) Stream

func (sshCmd *SSHCommander) Stream(cmd string) (<-chan Response, error)

func (*SSHCommander) Sudo

func (sshCmd *SSHCommander) Sudo() SudoSession

type SudoSession

type SudoSession interface {
	// Step down from sudo status
	StepDown()
}

Jump to

Keyboard shortcuts

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