scp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//FileToken crate file token
	FileToken = 'C'
	//DirToken create directory token
	DirToken = 'D'
	//TimestampToken timestamp token
	TimestampToken = 'T'
	//EndDirToken end of dir token
	EndDirToken = 'E'
	//WarningToken warning token
	WarningToken = 0x1
	//ErrorToken error token
	ErrorToken = 0x2
	// StatusOK
	StatusOK = 0x0
)
View Source
const (
	//DefaultDirMode folder mode default
	DefaultDirMode = os.ModeDir | 0755
)
View Source
const (
	//DefaultPort default SSH port
	DefaultPort = 22
)

Variables

This section is empty.

Functions

func ParseFileInfo

func ParseFileInfo(resp string, modified *time.Time) (os.FileInfo, error)

ParseFileInfo returns new info from SCP response

func ParseTimeResponse

func ParseTimeResponse(response string) (*time.Time, error)

ParseTimeResponse parases respons time

Types

type SCP

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

func New

func New(client *ssh.Client, fs afero.Fs, logger logr.Logger) *SCP

func (*SCP) Download

func (s *SCP) Download(ctx context.Context, remote, local string) error

Download downloads files from remote to local It is different from linux scp, if local path exists, it must be the same type with remote path If you are downloading a regular file, the local path must contain file name otherwise scp will use the last element of path as its file name

func (*SCP) Open

func (s *SCP) Open(dst string) (os.FileInfo, io.Reader, error)

func (*SCP) Stat

func (s *SCP) Stat(dst string) (os.FileInfo, error)

func (*SCP) Upload

func (s *SCP) Upload(ctx context.Context, local, remote string) error

Upload uploads files from local to remote It is different from linux scp, if remote path exists, it must be the same type with local path If you are uploading a regular file, the remote path must contain file name otherwise scp will use the last element of path as its file name

Jump to

Keyboard shortcuts

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