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) Connect ¶
Connect establishes the SSH+SFTP session. Must be called before Open/ReadDir.