Documentation
¶
Index ¶
- func CopyLocal(src, dst string) error
- func CopyRemote(sftpClient *SftpClient, src, dst string) error
- func ReadLocalFileBytes(filename string) ([]byte, error)
- func ReadRemoteFileBytes(sftpClient *SftpClient, remotePath string) ([]byte, error)
- func RunLocalCommandWithShell(command, username string, useShell bool, cfg *config.Config) (int, string, string, error)
- func RunRemoteCommandWithShell(pool *desopssshpool.Pool, host, command, username string, cfg *config.Config, ...) (int, string, string, error)
- func SetLocalFileMode(path, modeStr string) error
- func SetRemoteFileMode(sftpClient *SftpClient, path, modeStr string) error
- func StatLocal(path string, follow bool) (os.FileInfo, error)
- func StatRemote(sftpClient *SftpClient, path string) (os.FileInfo, error)
- func WriteLocalFile(filename string, data string) error
- func WriteRemoteFile(sftpClient *SftpClient, remotePath, data string) error
- type CommandOptions
- type CommandResult
- type SftpClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyRemote ¶
func CopyRemote(sftpClient *SftpClient, src, dst string) error
CopyRemote copies a file or directory recursively on the remote host using a pooled SFTP client
func ReadLocalFileBytes ¶
func ReadRemoteFileBytes ¶
func ReadRemoteFileBytes(sftpClient *SftpClient, remotePath string) ([]byte, error)
ReadRemoteFileBytes reads the content of a remote file as raw bytes using a pooled SFTP client
func RunLocalCommandWithShell ¶ added in v1.0.0
func RunRemoteCommandWithShell ¶ added in v1.0.0
func SetLocalFileMode ¶
func SetRemoteFileMode ¶
func SetRemoteFileMode(sftpClient *SftpClient, path, modeStr string) error
SetRemoteFileMode sets the mode of a remote file using a pooled SFTP client
func StatLocal ¶
StatLocal retrieves local file information. If follow is true, it follows symlinks (os.Stat). If follow is false, it stats the link itself (os.Lstat).
func StatRemote ¶
func StatRemote(sftpClient *SftpClient, path string) (os.FileInfo, error)
StatRemote retrieves remote file information using a pooled SFTP client
func WriteLocalFile ¶
func WriteRemoteFile ¶
func WriteRemoteFile(sftpClient *SftpClient, remotePath, data string) error
WriteRemoteFile writes data to a remote file using a pooled SFTP client
Types ¶
type CommandOptions ¶ added in v1.0.0
type CommandOptions struct {
Username string
UseShell bool
Interactive bool
UseSudo bool
SudoUser string
InteractiveSudo bool
BecomeFlags string
}
CommandOptions holds configuration for command execution
func NewCommandOptions ¶ added in v1.0.0
func NewCommandOptions(cfg *config.Config) *CommandOptions
NewCommandOptions creates a new CommandOptions with sensible defaults
func (*CommandOptions) WithInteractive ¶ added in v1.0.0
func (co *CommandOptions) WithInteractive() *CommandOptions
WithInteractive enables interactive execution
func (*CommandOptions) WithInteractiveSudo ¶ added in v1.0.0
func (co *CommandOptions) WithInteractiveSudo() *CommandOptions
WithInteractiveSudo enables interactive sudo
func (*CommandOptions) WithShell ¶ added in v1.0.0
func (co *CommandOptions) WithShell() *CommandOptions
WithShell enables shell execution
func (*CommandOptions) WithUsername ¶ added in v1.0.0
func (co *CommandOptions) WithUsername(username string) *CommandOptions
WithUsername sets the username for the command
type CommandResult ¶ added in v1.0.0
CommandResult represents the result of a command execution
type SftpClient ¶ added in v1.0.0
SftpClient wraps an SFTP client with SSH client information
func (*SftpClient) Close ¶ added in v1.0.0
func (s *SftpClient) Close() error
Close closes the SFTP client