Documentation ¶
Overview ¶
Package linuxssh provides Linux specific operations conducted via SSH
Index ¶
- func DeleteTree(ctx context.Context, s *ssh.Conn, baseDir string, files []string) error
- func GetAndDeleteFile(ctx context.Context, s *ssh.Conn, src, dst string, policy SymlinkPolicy) error
- func GetAndDeleteFilesInDir(ctx context.Context, s *ssh.Conn, src, dst string, policy SymlinkPolicy) error
- func GetFile(ctx context.Context, s *ssh.Conn, src, dst string, symlinkPolicy SymlinkPolicy) error
- func GetFileTail(ctx context.Context, s *ssh.Conn, src, dst string, startLine, maxSize int64) error
- func PutFiles(ctx context.Context, s *ssh.Conn, files map[string]string, ...) (bytes int64, err error)
- func ReadBootID(ctx context.Context, hst *ssh.Conn) (string, error)
- type SymlinkPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteTree ¶
DeleteTree deletes all relative paths in files from baseDir on the host. If a specified file is a directory, all files under it are recursively deleted. Non-existent files are ignored.
func GetAndDeleteFile ¶
func GetAndDeleteFile(ctx context.Context, s *ssh.Conn, src, dst string, policy SymlinkPolicy) error
GetAndDeleteFile is similar to GetFile, but it also deletes a remote file when it is successfully copied.
func GetAndDeleteFilesInDir ¶
func GetAndDeleteFilesInDir(ctx context.Context, s *ssh.Conn, src, dst string, policy SymlinkPolicy) error
GetAndDeleteFilesInDir copies all files in dst to src, assuming both dst and src are directories. It deletes the remote directory if all the files are successfully copied.
func GetFile ¶
GetFile copies a file or directory from the host to the local machine. dst is the full destination name for the file or directory being copied, not a destination directory into which it will be copied. dst will be replaced if it already exists.
func GetFileTail ¶
GetFileTail copies a file starting from startLine in src from the host to the local machine. dst is the full destination name for the file and it will be replaced if it already exists. If the same of the source data is bigger than maxSize, the beginning of the file will be truncated.
func PutFiles ¶
func PutFiles(ctx context.Context, s *ssh.Conn, files map[string]string, symlinkPolicy SymlinkPolicy) (bytes int64, err error)
PutFiles copies files on the local machine to the host. files describes a mapping from a local file path to a remote file path. For example, the call:
PutFiles(ctx, conn, map[string]string{"/src/from": "/dst/to"})
will copy the local file or directory /src/from to /dst/to on the remote host. Local file paths can be absolute or relative. Remote file paths must be absolute. SHA1 hashes of remote files are checked in advance to send updated files only. bytes is the amount of data sent over the wire (possibly after compression).
Types ¶
type SymlinkPolicy ¶
type SymlinkPolicy int
SymlinkPolicy describes how symbolic links should be handled by PutFiles.
const ( // PreserveSymlinks indicates that symlinks should be preserved during the copy. PreserveSymlinks SymlinkPolicy = iota // DereferenceSymlinks indicates that symlinks should be dereferenced and turned into normal files. DereferenceSymlinks )