executor

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Run 执行命令并返回标准输出内容
	Run(ctx context.Context, cmd string) (string, error)
	// RunWithSudo 提权执行命令
	RunWithSudo(ctx context.Context, cmd string) (string, error)
	// InteractiveWithSudo 开启交互式提权会话 (如 sudo -s)
	InteractiveWithSudo(ctx context.Context, args []string) error
}

Executor 定义命令执行接口

type LocalExecutor

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

LocalExecutor 本地执行器

func NewLocalExecutor

func NewLocalExecutor(password string) *LocalExecutor

func (*LocalExecutor) InteractiveWithSudo

func (e *LocalExecutor) InteractiveWithSudo(ctx context.Context, args []string) error

func (*LocalExecutor) Run

func (e *LocalExecutor) Run(ctx context.Context, cmd string) (string, error)

func (*LocalExecutor) RunWithSudo

func (e *LocalExecutor) RunWithSudo(ctx context.Context, cmd string) (string, error)

type SSHExecutor

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

SSHExecutor 包装 ssh.Client 以满足 Executor 接口

func NewSSHExecutor

func NewSSHExecutor(client *ssh.Client) *SSHExecutor

func (*SSHExecutor) InteractiveWithSudo

func (e *SSHExecutor) InteractiveWithSudo(ctx context.Context, args []string) error

func (*SSHExecutor) Run

func (e *SSHExecutor) Run(ctx context.Context, cmd string) (string, error)

func (*SSHExecutor) RunWithSudo

func (e *SSHExecutor) RunWithSudo(ctx context.Context, cmd string) (string, error)

type Transfer

type Transfer interface {
	// Copy 复制文件 (为了统一 SCP 和 本地复制)
	Copy(ctx context.Context, src, dst string) error
}

Transfer 定义文件传输接口

Jump to

Keyboard shortcuts

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