sftp

package module
v0.0.0-...-ea854ec Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	testcontainers.Container
}

Container represents the SFTP container type used in the module.

func Run

Run creates an instance of the SFTP container type. At least one user must be configured via WithUser, otherwise an error is returned.

Example
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/testcontainers/testcontainers-go"
	"github.com/testcontainers/testcontainers-go/modules/sftp"
)

func main() {
	// runSFTPContainer {
	ctx := context.Background()

	sftpContainer, err := sftp.Run(ctx, "atmoz/sftp:latest",
		sftp.WithUser("alice", "secret"),
	)
	defer func() {
		if err := testcontainers.TerminateContainer(sftpContainer); err != nil {
			log.Printf("failed to terminate container: %s", err)
		}
	}()
	if err != nil {
		log.Printf("failed to start container: %s", err)
		return
	}
	// }

	state, err := sftpContainer.State(ctx)
	if err != nil {
		log.Printf("failed to get container state: %s", err)
		return
	}

	fmt.Println(state.Running)

}
Output:
true

func (*Container) Address

func (c *Container) Address(ctx context.Context) (string, error)

Address returns the host:port address of the SFTP server, suitable for use with an SSH or SFTP client dial call.

type Option

type Option func(*options)

Option is an option for the SFTP container.

func WithUser

func WithUser(username, password string) Option

WithUser adds an SFTP user with the given username and password. The user's home directory will default to /home/<username>/upload. Multiple calls to WithUser will accumulate users.

func (Option) Customize

Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.

Jump to

Keyboard shortcuts

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