sftp

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package sftp implements repository storage in a directory on a remote server via the sftp protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory added in v0.16.0

func NewFactory() location.Factory

Types

type Config

type Config struct {
	User, Host, Port, Path string

	Command string `option:"command" help:"specify command to create sftp connection"`
	Args    string `option:"args"    help:"specify arguments for ssh"`

	Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
}

Config collects all information required to connect to an sftp server.

func NewConfig added in v0.14.0

func NewConfig() Config

NewConfig returns a new config with default options applied.

func ParseConfig

func ParseConfig(s string) (*Config, error)

ParseConfig parses the string s and extracts the sftp config. The supported configuration formats are sftp://user@host[:port]/directory and sftp:user@host:directory. The directory will be path Cleaned and can be an absolute path if it starts with a '/' (e.g. sftp://user@host//absolute and sftp:user@host:/absolute).

type SFTP

type SFTP struct {
	layout.Layout
	Config
	util.Modes
	// contains filtered or unexported fields
}

SFTP is a backend in a directory accessed via SFTP.

func Create

func Create(ctx context.Context, cfg Config) (*SFTP, error)

Create creates an sftp backend as described by the config by running "ssh" with the appropriate arguments (or cfg.Command, if set).

func Open

func Open(_ context.Context, cfg Config) (*SFTP, error)

Open opens an sftp backend as described by the config by running "ssh" with the appropriate arguments (or cfg.Command, if set).

func (*SFTP) Close

func (r *SFTP) Close() error

Close closes the sftp connection and terminates the underlying command.

func (*SFTP) Delete added in v0.8.0

func (r *SFTP) Delete(ctx context.Context) error

Delete removes all data in the backend.

func (*SFTP) Hasher added in v0.13.0

func (r *SFTP) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

func (*SFTP) IsNotExist

func (r *SFTP) IsNotExist(err error) bool

IsNotExist returns true if the error is caused by a not existing file.

func (*SFTP) IsPermanentError added in v0.17.0

func (r *SFTP) IsPermanentError(err error) bool

func (*SFTP) List

func (r *SFTP) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error

List runs fn for each file in the backend which has the type t. When an error occurs (or fn returns an error), List stops and returns it.

func (*SFTP) Load

func (r *SFTP) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*SFTP) Properties added in v0.18.0

func (r *SFTP) Properties() backend.Properties

func (*SFTP) Remove

func (r *SFTP) Remove(_ context.Context, h backend.Handle) error

Remove removes the content stored at name.

func (*SFTP) Save

Save stores data in the backend at the handle.

func (*SFTP) Stat

Stat returns information about a blob.

func (*SFTP) Warmup added in v0.18.0

func (r *SFTP) Warmup(_ context.Context, _ []backend.Handle) ([]backend.Handle, error)

Warmup not implemented

func (*SFTP) WarmupWait added in v0.18.0

func (r *SFTP) WarmupWait(_ context.Context, _ []backend.Handle) error

Jump to

Keyboard shortcuts

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