source

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package source provides the SFTP file source for xpro-oss (direct, or tunneled through SAP BTP Connectivity when configured). A source is a plain io/fs.FS, so it interoperates with fs.ReadFile, fs.ReadDir and testing/fstest; local directories need no wrapper at all, since os.DirFS already is one. See sftp.go.

A source that holds a session (like SFTP) is connected and closed by whoever creates it — never by the code that merely reads from it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KnownHostsCallback

func KnownHostsCallback(path string) (ssh.HostKeyCallback, error)

KnownHostsCallback returns a host-key callback that verifies servers against an OpenSSH known_hosts file.

Types

type SFTP

type SFTP struct {
	Dest      *destination.Destination
	Dialer    *connectivity.Dialer // nil = direct connection, no BTP
	Path      string
	RetryOpts sshclient.RetryOpts

	// HostKeyCallback verifies the server's host key. When nil, host keys are
	// not verified (a warning is logged on Connect) — build one with
	// KnownHostsCallback for any untrusted network.
	HostKeyCallback ssh.HostKeyCallback
	// contains filtered or unexported fields
}

SFTP is an fs.FS backed by one SFTP session, rooted at Path. When Dialer is non-nil, connections tunnel through the SAP BTP Connectivity SOCKS5 proxy via btp-go/sshclient — the same on-prem pattern used by BlueFunda's BTP services for SAP access. When Dialer is nil, xpro-oss dials directly, reusing btp-go's own auth-config logic (sshclient.SSHConfigFromDestination is dialer-independent), so the exact same code path works unmodified on AWS, GCP, or bare metal — no BTP dependency required.

The creator of an SFTP calls Connect once before use and Close when done; readers (such as process.Pipeline) just use it as an fs.FS. *sftp.Client is safe for concurrent use, so one session is shared across all concurrent batch goroutines within a run.

func (*SFTP) Close

func (s *SFTP) Close() error

Close tears down the SFTP and SSH connections, returning any close errors.

func (*SFTP) Connect

func (s *SFTP) Connect(ctx context.Context) error

Connect establishes the SSH+SFTP session. Must be called before Open/ReadDir.

func (*SFTP) Open

func (s *SFTP) Open(name string) (fs.File, error)

Open implements fs.FS, opening the named file under the configured Path.

func (*SFTP) ReadDir

func (s *SFTP) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS for the configured Path — a fast path so fs.ReadDir doesn't fall back to Open+ReadDir(-1)+Close.

Jump to

Keyboard shortcuts

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