Scert/backend/internal/deployment/client.go
xuans cd85d929ad 修复服务器 SSH 公钥自动部署
为服务器密钥流程增加仅 Shell 的 SSH 连接,避免远端 SFTP 子系统影响公钥部署和私钥登录验证,并记录脱敏阶段错误。
2026-09-27 16:01:21 +08:00

32 lines
1.0 KiB
Go

package deployment
import "context"
type CommandResult struct {
Output []byte
ExitCode int
}
type Client interface {
Lock(ctx context.Context, path string) error
Unlock(ctx context.Context, path string) error
MkdirAll(ctx context.Context, path string) error
List(ctx context.Context, path string) ([]string, error)
Exists(ctx context.Context, path string) (bool, error)
Upload(ctx context.Context, path string, data []byte, mode uint32) error
Rename(ctx context.Context, source, target string) error
Remove(ctx context.Context, path string) error
Run(ctx context.Context, command []string) (CommandResult, error)
InstallAuthorizedKey(ctx context.Context, publicKey string) error
Close() error
}
type ClientFactory interface {
Connect(ctx context.Context, server Server) (Client, error)
}
// ShellClientFactory 为只需要 SSH Shell 的操作提供连接入口,避免无关的 SFTP 子系统阻塞密钥部署。
type ShellClientFactory interface {
ConnectShell(ctx context.Context, server Server) (Client, error)
}