Documentation ¶
Index ¶
- Constants
- Variables
- func ExtractBinary(name string, needClose bool) (*os.File, error)
- func LoadConfigBytes(names ...string) (string, []byte, error)
- func MergeNodes(dstPtr *[]*Node, src []*Node)
- func PrepareConfig(config []*Node) error
- func RegisterLifecycle(lifecycle Lifecycle)
- func SetLogger(logger Logger)
- func WalkInterface(v reflect.Value, walked bool, solver ValueSolver) error
- type Client
- type CommonLifecycle
- func (d *CommonLifecycle) OnStderr(node *Node, line []byte) error
- func (d *CommonLifecycle) OnStdout(node *Node, line []byte) error
- func (d *CommonLifecycle) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
- func (d *CommonLifecycle) PostNewSession(node *Node, session *ssh.Session) error
- func (d *CommonLifecycle) PostSSHDial(node *Node, client *ssh.Client) error
- func (d *CommonLifecycle) PostSessionWait(node *Node) error
- func (d *CommonLifecycle) PostShell(node *Node, stdin io.WriteCloser) error
- func (d *CommonLifecycle) Priority() int
- type CustomTemplate
- type GithubRepository
- type Lifecycle
- type LifecycleAgent
- type LifecycleCallback
- type LifecycleComposite
- func (l *LifecycleComposite) OnStderr(node *Node, line []byte) error
- func (l *LifecycleComposite) OnStdout(node *Node, line []byte) error
- func (l *LifecycleComposite) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
- func (l *LifecycleComposite) PostNewSession(node *Node, session *ssh.Session) error
- func (l *LifecycleComposite) PostSSHDial(node *Node, client *ssh.Client) error
- func (l *LifecycleComposite) PostSessionWait(node *Node) error
- func (l *LifecycleComposite) PostShell(node *Node, stdin io.WriteCloser) error
- func (l *LifecycleComposite) Priority() int
- type LifecycleIO
- type LifecyclePassword
- type LifecyclePem
- type LifecycleQueue
- type LifecycleTerminal
- type Logger
- type Node
- type NodeCallbackShell
- type NodeCp
- type NodeExec
- type Repository
- type RuntimeSystem
- type TemplateNode
- type ValueSolver
- type VersionMeta
- type WriteCounter
Constants ¶
View Source
const ( TypeStr = "str" TypeParam = "param" )
View Source
const (
ApplicationName = "sshw"
)
Variables ¶
View Source
var (
DefaultCiphers = []string{
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm@openssh.com",
"chacha20-poly1305@openssh.com",
"arcfour256",
"arcfour128",
"arcfour",
"aes128-cbc",
"3des-cbc",
"blowfish-cbc",
"cast128-cbc",
"aes192-cbc",
"aes256-cbc",
}
)
View Source
var (
ErrorInterrupt = errors.New("interrupt")
)
Functions ¶
func ExtractBinary ¶ added in v1.5.0
func LoadConfigBytes ¶ added in v1.2.0
func MergeNodes ¶ added in v1.6.0
merge srcNode to dstNode only compare name and override, otherwise it is complex.
func PrepareConfig ¶ added in v1.4.0
func RegisterLifecycle ¶ added in v1.2.0
func RegisterLifecycle(lifecycle Lifecycle)
func WalkInterface ¶ added in v1.4.0
func WalkInterface(v reflect.Value, walked bool, solver ValueSolver) error
Types ¶
type CommonLifecycle ¶ added in v1.2.0
type CommonLifecycle struct { Name string PriorityFunc func() int PostInitClientConfigFunc func(node *Node, clientConfig *ssh.ClientConfig) error PostSSHDialFunc func(node *Node, client *ssh.Client) error PostNewSessionFunc func(node *Node, session *ssh.Session) error PostShellFunc func(node *Node, stdin io.WriteCloser) error OnStdoutFunc func(node *Node, line []byte) error OnStderrFunc func(node *Node, line []byte) error PostSessionWaitFunc func(node *Node) error }
CommonLifecycle is used to build Lifecycle quickly
func (*CommonLifecycle) OnStderr ¶ added in v1.2.0
func (d *CommonLifecycle) OnStderr(node *Node, line []byte) error
func (*CommonLifecycle) OnStdout ¶ added in v1.2.0
func (d *CommonLifecycle) OnStdout(node *Node, line []byte) error
func (*CommonLifecycle) PostInitClientConfig ¶ added in v1.2.0
func (d *CommonLifecycle) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
func (*CommonLifecycle) PostNewSession ¶ added in v1.2.0
func (d *CommonLifecycle) PostNewSession(node *Node, session *ssh.Session) error
func (*CommonLifecycle) PostSSHDial ¶ added in v1.2.0
func (d *CommonLifecycle) PostSSHDial(node *Node, client *ssh.Client) error
func (*CommonLifecycle) PostSessionWait ¶ added in v1.2.0
func (d *CommonLifecycle) PostSessionWait(node *Node) error
func (*CommonLifecycle) PostShell ¶ added in v1.2.0
func (d *CommonLifecycle) PostShell(node *Node, stdin io.WriteCloser) error
func (*CommonLifecycle) Priority ¶ added in v1.2.0
func (d *CommonLifecycle) Priority() int
type CustomTemplate ¶ added in v1.4.0
type CustomTemplate struct {
Templates []*TemplateNode
}
func ParseSshwTemplate ¶ added in v1.4.0
func ParseSshwTemplate(src string) *CustomTemplate
Parse string to Template For example: INPUT: ParseSshwTemplate("Foo${foo:a}bar") OUTPUT: []{{Type: TypeStr, Value: "Foo"}, {Type: TypeParam}, Value: "${foo:a}"}, {Type: TypeStr, Value: "bar"}}
func (*CustomTemplate) Execute ¶ added in v1.4.0
func (c *CustomTemplate) Execute() string
type GithubRepository ¶ added in v1.5.0
func (*GithubRepository) Download ¶ added in v1.5.0
func (g *GithubRepository) Download(versionMeta *VersionMeta) (*os.File, error)
Using version and filename to generate a remote url that is used to download file. Download it to file tmp. Then backup original file and replace it with Downloaded file.
func (*GithubRepository) LatestVersion ¶ added in v1.5.0
func (g *GithubRepository) LatestVersion() (*VersionMeta, error)
type Lifecycle ¶ added in v1.2.0
type Lifecycle interface { PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error PostSSHDial(node *Node, client *ssh.Client) error PostNewSession(node *Node, session *ssh.Session) error PostShell(node *Node, stdin io.WriteCloser) error OnStdout(node *Node, line []byte) error OnStderr(node *Node, line []byte) error PostSessionWait(node *Node) error Priority() int }
type LifecycleAgent ¶ added in v1.2.0
type LifecycleAgent struct {
// contains filtered or unexported fields
}
func (*LifecycleAgent) PostInitClientConfig ¶ added in v1.2.0
func (l *LifecycleAgent) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
func (*LifecycleAgent) PostNewSession ¶ added in v1.2.0
func (l *LifecycleAgent) PostNewSession(node *Node, session *ssh.Session) error
func (*LifecycleAgent) PostSSHDial ¶ added in v1.2.0
func (l *LifecycleAgent) PostSSHDial(node *Node, client *ssh.Client) error
func (*LifecycleAgent) Priority ¶ added in v1.2.0
func (l *LifecycleAgent) Priority() int
type LifecycleCallback ¶ added in v1.2.0
func (*LifecycleCallback) OnStdout ¶ added in v1.2.0
func (l *LifecycleCallback) OnStdout(node *Node, line []byte) error
func (*LifecycleCallback) PostShell ¶ added in v1.2.0
func (l *LifecycleCallback) PostShell(node *Node, stdin io.WriteCloser) error
type LifecycleComposite ¶ added in v1.2.0
type LifecycleComposite struct {
// contains filtered or unexported fields
}
func (*LifecycleComposite) OnStderr ¶ added in v1.2.0
func (l *LifecycleComposite) OnStderr(node *Node, line []byte) error
func (*LifecycleComposite) OnStdout ¶ added in v1.2.0
func (l *LifecycleComposite) OnStdout(node *Node, line []byte) error
func (*LifecycleComposite) PostInitClientConfig ¶ added in v1.2.0
func (l *LifecycleComposite) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
func (*LifecycleComposite) PostNewSession ¶ added in v1.2.0
func (l *LifecycleComposite) PostNewSession(node *Node, session *ssh.Session) error
func (*LifecycleComposite) PostSSHDial ¶ added in v1.2.0
func (l *LifecycleComposite) PostSSHDial(node *Node, client *ssh.Client) error
func (*LifecycleComposite) PostSessionWait ¶ added in v1.2.0
func (l *LifecycleComposite) PostSessionWait(node *Node) error
func (*LifecycleComposite) PostShell ¶ added in v1.2.0
func (l *LifecycleComposite) PostShell(node *Node, stdin io.WriteCloser) error
func (*LifecycleComposite) Priority ¶ added in v1.2.0
func (l *LifecycleComposite) Priority() int
type LifecycleIO ¶ added in v1.2.0
type LifecycleIO struct { }
func (*LifecycleIO) OnStderr ¶ added in v1.2.0
func (*LifecycleIO) OnStderr(node *Node, bytes []byte) error
func (*LifecycleIO) OnStdout ¶ added in v1.2.0
func (*LifecycleIO) OnStdout(node *Node, bytes []byte) error
func (*LifecycleIO) Priority ¶ added in v1.2.0
func (*LifecycleIO) Priority() int
type LifecyclePassword ¶ added in v1.2.0
type LifecyclePassword struct { }
func (*LifecyclePassword) PostInitClientConfig ¶ added in v1.2.0
func (*LifecyclePassword) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
type LifecyclePem ¶ added in v1.2.0
type LifecyclePem struct { }
func (*LifecyclePem) PostInitClientConfig ¶ added in v1.2.0
func (*LifecyclePem) PostInitClientConfig(node *Node, clientConfig *ssh.ClientConfig) error
type LifecycleQueue ¶ added in v1.2.0
type LifecycleQueue []Lifecycle
func (*LifecycleQueue) Len ¶ added in v1.2.0
func (l *LifecycleQueue) Len() int
func (*LifecycleQueue) Less ¶ added in v1.2.0
func (l *LifecycleQueue) Less(i, j int) bool
func (*LifecycleQueue) Pop ¶ added in v1.2.0
func (l *LifecycleQueue) Pop() interface{}
func (*LifecycleQueue) Push ¶ added in v1.2.0
func (l *LifecycleQueue) Push(x interface{})
func (*LifecycleQueue) Swap ¶ added in v1.2.0
func (l *LifecycleQueue) Swap(i, j int)
type LifecycleTerminal ¶ added in v1.2.0
type LifecycleTerminal struct { Callback func() // contains filtered or unexported fields }
func (*LifecycleTerminal) PostNewSession ¶ added in v1.2.0
func (l *LifecycleTerminal) PostNewSession(node *Node, session *ssh.Session) error
func (*LifecycleTerminal) PostSessionWait ¶ added in v1.2.0
func (l *LifecycleTerminal) PostSessionWait(node *Node) error
func (*LifecycleTerminal) PostShell ¶ added in v1.2.0
func (l *LifecycleTerminal) PostShell(node *Node, stdin io.WriteCloser) error
func (*LifecycleTerminal) Priority ¶ added in v1.2.0
func (*LifecycleTerminal) Priority() int
type Logger ¶
type Node ¶
type Node struct { Name string `yaml:"name"` Alias string `yaml:"alias,omitempty"` ExecsPre []*NodeExec `yaml:"execs-pre,omitempty"` ExecsStop []*NodeExec `yaml:"execs-stop,omitempty"` Host string `yaml:"host,omitempty"` User string `yaml:"user,omitempty"` Port int `yaml:"port,omitempty"` KeyPath string `yaml:"keypath,omitempty"` Passphrase string `yaml:"passphrase,omitempty"` Password string `yaml:"password,omitempty"` CallbackShells []*NodeCallbackShell `yaml:"callback-shells,omitempty"` Children []*Node `yaml:"children,omitempty"` Jump []*Node `yaml:"jump,omitempty"` MergeIgnore bool `yaml:"merge-ignore,omitempty"` }
func LoadSshConfig ¶ added in v1.2.0
type NodeCallbackShell ¶ added in v1.3.0
type Repository ¶ added in v1.5.0
type Repository interface { // get remote version LatestVersion() (*VersionMeta, error) // download remote file to specified path Download(versionMeta *VersionMeta) (*os.File, error) }
type RuntimeSystem ¶ added in v1.5.0
type TemplateNode ¶ added in v1.4.0
func NewParamNode ¶ added in v1.4.0
func NewParamNode(v string) *TemplateNode
func NewStrNode ¶ added in v1.4.0
func NewStrNode(v string) *TemplateNode
type VersionMeta ¶ added in v1.5.0
type WriteCounter ¶ added in v1.5.0
WriteCounter counts the number of bytes written to it. It implements to the io.Writer interface and we can pass this into io.TeeReader() which will report progress on each write cycle.
func NewWriteCounter ¶ added in v1.5.0
func NewWriteCounter() *WriteCounter
func (WriteCounter) PrintProgress ¶ added in v1.5.0
func (wc WriteCounter) PrintProgress()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.