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 ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
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
type Option ¶
type Option func(*options)
Option is an option for the SFTP container.
func WithUser ¶
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 ¶
func (o Option) Customize(*testcontainers.GenericContainerRequest) error
Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.
Click to show internal directories.
Click to hide internal directories.