connector

package
v0.0.0-...-28befd1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCommand

func WithCommand(command string) func(*CommonTask)

func WithDesc

func WithDesc(desc string) func(*CommonTask)

func WithEnvironments

func WithEnvironments(envs map[string]string) func(*CommonTask)

func WithLocal

func WithLocal(local bool) func(*CommonTask)

func WithName

func WithName(name string) func(*CommonTask)

func WithShell

func WithShell(shell string) func(*CommonTask)

func WithStdin

func WithStdin(stdin func() (io.Reader, error)) func(*CommonTask)

func WithSudo

func WithSudo(sudo bool) func(*CommonTask)

Types

type CommonTask

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

CommonTask is minimum unit of task with target runners for ops to run

func NewCommonTask

func NewCommonTask(options ...func(*CommonTask)) *CommonTask

func (*CommonTask) Command

func (ct *CommonTask) Command() string

Command return executable sh/bash commands

func (*CommonTask) Desc

func (ct *CommonTask) Desc() string

func (*CommonTask) Environments

func (ct *CommonTask) Environments() map[string]string

func (*CommonTask) Local

func (ct *CommonTask) Local() bool

func (*CommonTask) Name

func (ct *CommonTask) Name() string

func (*CommonTask) Shell

func (ct *CommonTask) Shell() string

func (*CommonTask) Stdin

func (ct *CommonTask) Stdin() func() (io.Reader, error)

func (*CommonTask) Sudo

func (ct *CommonTask) Sudo() bool

type Connector

type Connector interface {
	ID() string
	Local() bool
	Connect() error
	Close() error
	Run(Task, *RunOptions) error
	Wait() error
	Stdin() io.WriteCloser
	Stderr() io.Reader
	Stdout() io.Reader
	Promet() string
	SetPromet(string)
	Host() string
	Signal(os.Signal) error
}

Connector build a tunnel to run commands between host and local/remote servers.

type LocalConnector

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

func NewLocalConnector

func NewLocalConnector() *LocalConnector

func (*LocalConnector) Close

func (r *LocalConnector) Close() error

func (*LocalConnector) Connect

func (r *LocalConnector) Connect() error

func (*LocalConnector) Host

func (r *LocalConnector) Host() string

func (*LocalConnector) ID

func (r *LocalConnector) ID() string

func (*LocalConnector) Local

func (r *LocalConnector) Local() bool

func (*LocalConnector) Promet

func (r *LocalConnector) Promet() string

func (*LocalConnector) Run

func (r *LocalConnector) Run(tr Task, options *RunOptions) error

func (*LocalConnector) SetPromet

func (r *LocalConnector) SetPromet(promet string)

func (*LocalConnector) Signal

func (r *LocalConnector) Signal(sig os.Signal) error

func (*LocalConnector) Stderr

func (r *LocalConnector) Stderr() io.Reader

func (*LocalConnector) Stdin

func (r *LocalConnector) Stdin() io.WriteCloser

func (*LocalConnector) Stdout

func (r *LocalConnector) Stdout() io.Reader

func (*LocalConnector) Upload

func (r *LocalConnector) Upload(src, dest string) error

func (*LocalConnector) Wait

func (r *LocalConnector) Wait() error

type RunOptions

type RunOptions struct {
	Debug  bool
	DryRun bool
}

type SSHConnector

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

func NewSSHConnector

func NewSSHConnector(host string, options ...SSHTaskRunnerOption) *SSHConnector

func (*SSHConnector) Close

func (r *SSHConnector) Close() error

func (*SSHConnector) Connect

func (r *SSHConnector) Connect() error

func (*SSHConnector) Host

func (r *SSHConnector) Host() string

func (*SSHConnector) ID

func (r *SSHConnector) ID() string

func (*SSHConnector) Local

func (r *SSHConnector) Local() bool

func (*SSHConnector) Promet

func (r *SSHConnector) Promet() string

func (*SSHConnector) Run

func (r *SSHConnector) Run(tr Task, options *RunOptions) error

func (*SSHConnector) SetPromet

func (r *SSHConnector) SetPromet(promet string)

func (*SSHConnector) Signal

func (r *SSHConnector) Signal(sig os.Signal) error

func (*SSHConnector) Stderr

func (r *SSHConnector) Stderr() io.Reader

func (*SSHConnector) Stdin

func (r *SSHConnector) Stdin() io.WriteCloser

func (*SSHConnector) Stdout

func (r *SSHConnector) Stdout() io.Reader

func (*SSHConnector) Wait

func (r *SSHConnector) Wait() error

type SSHTaskRunnerOption

type SSHTaskRunnerOption func(*SSHConnector)

func WithPassword

func WithPassword(password string) SSHTaskRunnerOption

func WithPort

func WithPort(port uint) SSHTaskRunnerOption

func WithUser

func WithUser(user string) SSHTaskRunnerOption

type Task

type Task interface {
	Shell() string
	Command() string
	Environments() map[string]string
	Stdin() func() (io.Reader, error)
	Sudo() bool
	Local() bool
	Name() string
	Desc() string
}

TaskRun executable/runnable task

Jump to

Keyboard shortcuts

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