sftp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.0.0

A Client is the full interface for interacting with the remote server. It combines the interfaces above.

type ClientWrapper

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

ClientWrapper Our ClientWrapper is a wrapper around the pkg/sftp Client that only exposes the methods that we actually need.

func NewClient

func NewClient(credentials SSHCredentials) (*ClientWrapper, error)

func (*ClientWrapper) CanRunRemoteCommand

func (c *ClientWrapper) CanRunRemoteCommand(cmd string) bool

func (*ClientWrapper) Close

func (c *ClientWrapper) Close() error

func (*ClientWrapper) Delete

func (c *ClientWrapper) Delete(dst string) error

func (*ClientWrapper) Mkdir added in v1.0.0

func (c *ClientWrapper) Mkdir(dst string) error

func (*ClientWrapper) NewSession

func (c *ClientWrapper) NewSession() (*ssh.Session, error)

func (*ClientWrapper) Open

func (c *ClientWrapper) Open(path string) (*_sftp.File, error)

func (*ClientWrapper) ReadDir

func (c *ClientWrapper) ReadDir(path string) ([]os.FileInfo, error)

func (*ClientWrapper) RunRemoteCommand

func (c *ClientWrapper) RunRemoteCommand(command string) (io.Reader, error)

func (*ClientWrapper) Upload

func (c *ClientWrapper) Upload(r io.Reader, dst string) error

type FileUploadDeleter added in v1.0.0

type FileUploadDeleter interface {
	Upload(r io.Reader, dst string) error
	Delete(dst string) error
	Mkdir(dst string) error
}

FileUploadDeleter is an interface that allows us to upload, delete, and create directories on the remote server. An object may choose to use this interface instead of a full Client if it only needs to upload/delete files.

type RemoteCommandRunner added in v1.0.0

type RemoteCommandRunner interface {
	CanRunRemoteCommand(command string) bool
	RunRemoteCommand(command string) (io.Reader, error)
}

RemoteCommandRunner is an interface that allows us to check if the remote server can run a command, and then run it. An object may choose to use this interface instead of a full Client if it only needs to run commands.

type RemoteFileReader added in v1.0.0

type RemoteFileReader interface {
	ReadDir(path string) ([]os.FileInfo, error)
	Open(path string) (*_sftp.File, error)
	NewSession() (*ssh.Session, error)
}

FileEmitter is an interface that allows us to download files from the remote server. An object may choose to use this interface instead of a full Client if it only needs to download files.

type SSHCredentials

type SSHCredentials struct {
	User string
	Pass string
	Host string
	Port string
}

Jump to

Keyboard shortcuts

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