resource

package
v0.0.0-...-34b02ed Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResourceNotOpened = errors.New("resource not opened")

Functions

func NewAuthMethodFromPrivateKey

func NewAuthMethodFromPrivateKey(privateKey []byte) (ssh.AuthMethod, error)

func NewAuthMethodFromPrivateKeyFile

func NewAuthMethodFromPrivateKeyFile(privateKeyFile string) (ssh.AuthMethod, error)

Types

type HTTPInterceptor

type HTTPInterceptor struct {
	Headers  map[string]string
	Delegate http.RoundTripper
}

func (*HTTPInterceptor) RoundTrip

func (ic *HTTPInterceptor) RoundTrip(req *http.Request) (*http.Response, error)

type HTTPResource

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

func NewHTTPResource

func NewHTTPResource(
	logger *slog.Logger,
	url string,
) *HTTPResource

func NewHTTPResourceWithHeaders

func NewHTTPResourceWithHeaders(
	logger *slog.Logger,
	url string,
	headers map[string]string,
) *HTTPResource

func (*HTTPResource) Close

func (r *HTTPResource) Close(_ context.Context) error

func (*HTTPResource) GetID

func (r *HTTPResource) GetID() string

func (*HTTPResource) Open

func (r *HTTPResource) Open(ctx context.Context) error

func (*HTTPResource) Read

func (r *HTTPResource) Read(p []byte) (n int, err error)

func (*HTTPResource) WithRequestTimeout

func (r *HTTPResource) WithRequestTimeout(timeout time.Duration) *HTTPResource

type ISftpClient

type ISftpClient interface {
	Open(ctx context.Context) error
	Close(ctx context.Context) error
	OpenFile(path string, flag int) (*sftp.File, error)
}

type LocalResource

type LocalResource struct {
	Logger   *slog.Logger
	FilePath string
	Flag     int
	FileMode fs.FileMode
	// contains filtered or unexported fields
}

func NewLocalResource

func NewLocalResource(
	logger *slog.Logger,
	filePath string,
) *LocalResource

func (*LocalResource) Close

func (r *LocalResource) Close(_ context.Context) error

func (*LocalResource) GetID

func (r *LocalResource) GetID() string

func (*LocalResource) Open

func (r *LocalResource) Open(_ context.Context) error

func (*LocalResource) Read

func (r *LocalResource) Read(p []byte) (n int, err error)

func (*LocalResource) WithDefaultFileMode

func (r *LocalResource) WithDefaultFileMode() *LocalResource

func (*LocalResource) WithFileMode

func (r *LocalResource) WithFileMode(fileMode fs.FileMode) *LocalResource

func (*LocalResource) WithFlag

func (r *LocalResource) WithFlag(flag int) *LocalResource

func (*LocalResource) WithWriteFlag

func (r *LocalResource) WithWriteFlag() *LocalResource

func (*LocalResource) Write

func (r *LocalResource) Write(p []byte) (n int, err error)

type MemoryResource

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

func NewMemoryResource

func NewMemoryResource(
	logger *slog.Logger,
	identifier string,
) *MemoryResource

func (*MemoryResource) Close

func (r *MemoryResource) Close(_ context.Context) error

func (*MemoryResource) GetData

func (r *MemoryResource) GetData() []byte

func (*MemoryResource) GetID

func (r *MemoryResource) GetID() string

func (*MemoryResource) Open

func (r *MemoryResource) Open(_ context.Context) error

func (*MemoryResource) Read

func (r *MemoryResource) Read(p []byte) (n int, err error)

func (*MemoryResource) Write

func (r *MemoryResource) Write(p []byte) (n int, err error)

type SSHServer

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

func NewSSHServer

func NewSSHServer(
	address string,
	config *ssh.ClientConfig,
) *SSHServer

type SftpClient

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

resource on sftp server

func NewSftpClient

func NewSftpClient(logger *slog.Logger, destServer *SSHServer) *SftpClient

func (*SftpClient) Close

func (c *SftpClient) Close(_ context.Context) error

func (*SftpClient) Open

func (c *SftpClient) Open(_ context.Context) error

func (*SftpClient) OpenFile

func (c *SftpClient) OpenFile(path string, flag int) (*sftp.File, error)

type SftpResource

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

resource on sftp server

func NewSftpResource

func NewSftpResource(logger *slog.Logger, client ISftpClient, filePath string) *SftpResource

func (*SftpResource) Close

func (r *SftpResource) Close(ctx context.Context) error

func (*SftpResource) GetID

func (r *SftpResource) GetID() string

func (*SftpResource) Open

func (r *SftpResource) Open(ctx context.Context) error

func (*SftpResource) Read

func (r *SftpResource) Read(p []byte) (n int, err error)

func (*SftpResource) WithFlag

func (r *SftpResource) WithFlag(flag int) *SftpResource

func (*SftpResource) Write

func (r *SftpResource) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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