Documentation
¶
Index ¶
- func QuotePOSIXShellArg(value string) string
- type Executor
- func (executor *Executor) Close()
- func (executor *Executor) CreateTempDir() (string, error)
- func (executor *Executor) CreateTempDirContext(ctx context.Context) (string, error)
- func (executor *Executor) IsRoot() bool
- func (executor *Executor) RemoveTempDir(tempDir string) error
- func (executor *Executor) RemoveTempDirContext(ctx context.Context, tempDir string) error
- func (executor *Executor) Run(command string, input []byte, privileged bool) ([]byte, error)
- func (executor *Executor) RunContext(ctx context.Context, command string, input []byte, privileged bool) ([]byte, error)
- func (executor *Executor) Upload(remoteFile string, content []byte) error
- func (executor *Executor) UploadContext(ctx context.Context, remoteFile string, content []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuotePOSIXShellArg ¶
QuotePOSIXShellArg 将单个值安全编码为 POSIX shell 参数。
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor 封装通用 SSH 认证、远端命令执行和受限临时文件传输。
func NewExecutor ¶
func NewExecutor(sshConfig *config.SSHConfig, purpose, tempPrefix string, knownHostsFiles ...string) (*Executor, error)
NewExecutor 建立支持密码或私钥认证并带 TOFU 主机密钥校验的 SSH 连接。
func NewExecutorContext ¶
func NewExecutorContext(ctx context.Context, sshConfig *config.SSHConfig, purpose, tempPrefix string, knownHostsFiles ...string) (*Executor, error)
NewExecutorContext 建立可由调用方取消的 SSH 连接。
func (*Executor) CreateTempDir ¶
CreateTempDir 在远端创建仅 SSH 用户可读写的业务专用临时目录。
func (*Executor) CreateTempDirContext ¶
CreateTempDirContext 在远端创建临时目录并响应调用方取消。
func (*Executor) RemoveTempDir ¶
RemoveTempDir 清理经过固定前缀校验的 SSH 临时目录。
func (*Executor) RemoveTempDirContext ¶
RemoveTempDirContext 清理经过固定前缀校验的远端临时目录。
func (*Executor) RunContext ¶
func (executor *Executor) RunContext(ctx context.Context, command string, input []byte, privileged bool) ([]byte, error)
RunContext 执行 SSH 命令,并在取消或硬超时后关闭会话并等待其退出。
Click to show internal directories.
Click to hide internal directories.