client

package
v0.0.0-...-9e2b752 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//AuthTypePassword is the type of ssh by password
	AuthTypePassword authType = iota
	//AuthTypePublicKey is the type of ssh by public key
	AuthTypePublicKey
)
View Source
const (
	//RollbackTypeNone means no rollback
	RollbackTypeNone rollbackType = iota
	//RollbackTypeOne means just rollback single command,yet last failed one
	RollbackTypeOne
	//RollbackTypeBackTrace means rollback backtrack util one without rollback or the first one
	RollbackTypeBackTrace
	//RollbackTypeAll which is recommended is rollback all,this requires that each command should have rollback command
	RollbackTypeAll
)

Variables

View Source
var (
	//ErrEmptyCommand defines empty command error
	ErrEmptyCommand = errors.New("empty command")
	//ErrRollbackTypeAllWithNoRollbackCmd defines rollback type all with no rollback command
	ErrRollbackTypeAllWithNoRollbackCmd = errors.New("rollback type all with no rollback command")

	//ErrRunWithEmptyCommand defines run with empty command
	ErrRunWithEmptyCommand = errors.New("run with empty command")
)

Functions

This section is empty.

Types

type Client

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

Client is a single ssh client

func NewClientByPassword

func NewClientByPassword(address, user, password string, rollbackTyp rollbackType) *Client

NewClientByPassword creates client by password

func (*Client) Err

func (c *Client) Err() error

func (*Client) RunCmds

func (c *Client) RunCmds(cmds []*Command) ([]*Command, error)

RunCmds will run command step by step if error occurs,return the error will rollback if one command occurs according to the client rollback type

type Command

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

Command defines command for run

func NewCommand

func NewCommand(name, cmd, checkCmd, rollbackCmd string, checkExpectResult string, cmdEnv, checkEnv, rollbackEnv map[string]string, timeout time.Duration) *Command

NewCommand will get a new command by input info

func (*Command) AddCmdEnv

func (c *Command) AddCmdEnv(env map[string]string)

AddCmdEnv is used for add cmd environment variables

func (*Command) AddDetectEnv

func (c *Command) AddDetectEnv(env map[string]string)

AddDetectEnv is used for add check cmd environment variables

func (*Command) CheckErrOutput

func (c *Command) CheckErrOutput() string

func (*Command) CheckOutput

func (c *Command) CheckOutput() string

func (*Command) ErrOutput

func (c *Command) ErrOutput() string

ErrOutput will get command err info if cmd run failed

func (*Command) Name

func (c *Command) Name() string

Name will get Command's name

func (*Command) Output

func (c *Command) Output() string

Output will get command run result if cmd run success

func (*Command) RollbackErrOutput

func (c *Command) RollbackErrOutput() string

func (*Command) RollbackOutput

func (c *Command) RollbackOutput() string

func (*Command) Status

func (c *Command) Status() CommandStatus

Status will get Command's status

func (*Command) StatusName

func (c *Command) StatusName() string

StatusName will get Command's status in string

type CommandStatus

type CommandStatus byte

CommandStatus defines command status

const (
	//CommandStatusInit is the default command status
	CommandStatusInit CommandStatus = iota
	//CommandStatusSuccess means this command runs successfully
	CommandStatusSuccess
	//CommandStatusFailed means this command runs failed,and with no rollback
	CommandStatusFailed
	//CommandStatusRollbackSuccess means the command runs failed,the rollback command runs successfully
	CommandStatusRollbackSuccess
	//CommandStatusRollbackFailed means both the command and rollback command run failed
	CommandStatusRollbackFailed
	//CommandStatusCheckFailed means check cmd runs failed
	CommandStatusCheckFailed
	//CommandStatusCheckSuccess means check cmd runs successfully
	CommandStatusCheckSuccess
)

type Env

type Env map[string]string

Env defines command environment variables need to set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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