Documentation
¶
Index ¶
- Variables
- func ForSQL(port network.Port, driver string, ...) *waitForSQL
- func Walk(root *Strategy, visit VisitFunc) error
- type ExecStrategy
- func (ws *ExecStrategy) String() string
- func (ws *ExecStrategy) Timeout() *time.Duration
- func (ws *ExecStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *ExecStrategy) WithExitCode(exitCode int) *ExecStrategy
- func (ws *ExecStrategy) WithExitCodeMatcher(exitCodeMatcher func(exitCode int) bool) *ExecStrategy
- func (ws *ExecStrategy) WithPollInterval(pollInterval time.Duration) *ExecStrategy
- func (ws *ExecStrategy) WithResponseMatcher(matcher func(body io.Reader) bool) *ExecStrategy
- func (ws *ExecStrategy) WithTimeout(startupTimeout time.Duration) *ExecStrategy
- type ExitStrategy
- func (ws *ExitStrategy) String() string
- func (ws *ExitStrategy) Timeout() *time.Duration
- func (ws *ExitStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *ExitStrategy) WithPollInterval(pollInterval time.Duration) *ExitStrategy
- func (ws *ExitStrategy) WithTimeout(exitTimeout time.Duration) *ExitStrategy
- type FileStrategy
- func (ws *FileStrategy) String() string
- func (ws *FileStrategy) Timeout() *time.Duration
- func (ws *FileStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *FileStrategy) WithMatcher(matcher func(io.Reader) error) *FileStrategy
- func (ws *FileStrategy) WithPollInterval(pollInterval time.Duration) *FileStrategy
- func (ws *FileStrategy) WithTimeout(startupTimeout time.Duration) *FileStrategy
- type HTTPStrategy
- func (ws *HTTPStrategy) String() string
- func (ws *HTTPStrategy) Timeout() *time.Duration
- func (ws *HTTPStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *HTTPStrategy) WithAllowInsecure(allowInsecure bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithBasicAuth(username, password string) *HTTPStrategy
- func (ws *HTTPStrategy) WithBody(reqdata io.Reader) *HTTPStrategy
- func (ws *HTTPStrategy) WithForcedIPv4LocalHost() *HTTPStrategy
- func (ws *HTTPStrategy) WithHeaders(headers map[string]string) *HTTPStrategy
- func (ws *HTTPStrategy) WithMethod(method string) *HTTPStrategy
- func (ws *HTTPStrategy) WithPollInterval(pollInterval time.Duration) *HTTPStrategy
- func (ws *HTTPStrategy) WithPort(port network.Port) *HTTPStrategy
- func (ws *HTTPStrategy) WithResponseHeadersMatcher(matcher func(http.Header) bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithResponseMatcher(matcher func(body io.Reader) bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithStatus(status int) *HTTPStrategy
- func (ws *HTTPStrategy) WithStatusCodeMatcher(statusCodeMatcher func(status int) bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithTLS(useTLS bool, tlsconf ...*tls.Config) *HTTPStrategy
- func (ws *HTTPStrategy) WithTimeout(timeout time.Duration) *HTTPStrategy
- type HealthStrategy
- func (ws *HealthStrategy) String() string
- func (ws *HealthStrategy) Timeout() *time.Duration
- func (ws *HealthStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *HealthStrategy) WithPollInterval(pollInterval time.Duration) *HealthStrategy
- func (ws *HealthStrategy) WithTimeout(startupTimeout time.Duration) *HealthStrategy
- type HostPortStrategy
- func (hp *HostPortStrategy) SkipExternalCheck() *HostPortStrategy
- func (hp *HostPortStrategy) SkipInternalCheck() *HostPortStrategy
- func (hp *HostPortStrategy) String() string
- func (hp *HostPortStrategy) Timeout() *time.Duration
- func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (hp *HostPortStrategy) WithPollInterval(pollInterval time.Duration) *HostPortStrategy
- func (hp *HostPortStrategy) WithTimeout(startupTimeout time.Duration) *HostPortStrategy
- type LogStrategy
- func (ws *LogStrategy) AsRegexp() *LogStrategy
- func (ws *LogStrategy) String() string
- func (ws *LogStrategy) Submatch(callback func(pattern string, matches [][][]byte) error) *LogStrategy
- func (ws *LogStrategy) Timeout() *time.Duration
- func (ws *LogStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *LogStrategy) WithOccurrence(o int) *LogStrategy
- func (ws *LogStrategy) WithPollInterval(pollInterval time.Duration) *LogStrategy
- func (ws *LogStrategy) WithTimeout(timeout time.Duration) *LogStrategy
- type MultiStrategy
- func (ms *MultiStrategy) String() string
- func (ms *MultiStrategy) Timeout() *time.Duration
- func (ms *MultiStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ms *MultiStrategy) WithDeadline(deadline time.Duration) *MultiStrategy
- func (ms *MultiStrategy) WithStartupTimeoutDefault(timeout time.Duration) *MultiStrategy
- type NopStrategy
- type NopStrategyTarget
- func (st *NopStrategyTarget) CopyFromContainer(_ context.Context, _ string) (io.ReadCloser, error)
- func (st *NopStrategyTarget) Exec(_ context.Context, _ []string, _ ...exec.ProcessOption) (int, io.Reader, error)
- func (st *NopStrategyTarget) Host(_ context.Context) (string, error)
- func (st *NopStrategyTarget) Inspect(_ context.Context) (client.ContainerInspectResult, error)
- func (st *NopStrategyTarget) Logger() *slog.Logger
- func (st *NopStrategyTarget) Logs(_ context.Context) (io.ReadCloser, error)
- func (st *NopStrategyTarget) MappedPort(_ context.Context, n network.Port) (network.Port, error)
- func (st *NopStrategyTarget) State(_ context.Context) (*container.State, error)
- type PermanentError
- type Strategy
- type StrategyTarget
- type StrategyTimeout
- type TLSStrategy
- func (ws *TLSStrategy) String() string
- func (ws *TLSStrategy) TLSConfig() *tls.Config
- func (ws *TLSStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *TLSStrategy) WithCert(certPEMFile, keyPEMFile string) *TLSStrategy
- func (ws *TLSStrategy) WithPollInterval(pollInterval time.Duration) *TLSStrategy
- func (ws *TLSStrategy) WithRootCAs(files ...string) *TLSStrategy
- func (ws *TLSStrategy) WithServerName(serverName string) *TLSStrategy
- func (ws *TLSStrategy) WithTimeout(startupTimeout time.Duration) *TLSStrategy
- type VisitFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrVisitStop is used as a return value from [VisitFunc] to stop the walk. // It is not returned as an error by any function. ErrVisitStop = errors.New("stop the walk") // ErrVisitRemove is used as a return value from [VisitFunc] to have the current node removed. // It is not returned as an error by any function. ErrVisitRemove = errors.New("remove this strategy") )
Functions ¶
Types ¶
type ExecStrategy ¶
type ExecStrategy struct {
// additional properties
ExitCodeMatcher func(exitCode int) bool
ResponseMatcher func(body io.Reader) bool
PollInterval time.Duration
// contains filtered or unexported fields
}
func ForExec ¶
func ForExec(cmd []string) *ExecStrategy
ForExec is a convenience method to assign ExecStrategy
func NewExecStrategy ¶
func NewExecStrategy(cmd []string) *ExecStrategy
NewExecStrategy constructs an Exec strategy ...
func (*ExecStrategy) String ¶
func (ws *ExecStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*ExecStrategy) Timeout ¶
func (ws *ExecStrategy) Timeout() *time.Duration
func (*ExecStrategy) WaitUntilReady ¶
func (ws *ExecStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
func (*ExecStrategy) WithExitCode ¶
func (ws *ExecStrategy) WithExitCode(exitCode int) *ExecStrategy
func (*ExecStrategy) WithExitCodeMatcher ¶
func (ws *ExecStrategy) WithExitCodeMatcher(exitCodeMatcher func(exitCode int) bool) *ExecStrategy
func (*ExecStrategy) WithPollInterval ¶
func (ws *ExecStrategy) WithPollInterval(pollInterval time.Duration) *ExecStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*ExecStrategy) WithResponseMatcher ¶
func (ws *ExecStrategy) WithResponseMatcher(matcher func(body io.Reader) bool) *ExecStrategy
func (*ExecStrategy) WithTimeout ¶
func (ws *ExecStrategy) WithTimeout(startupTimeout time.Duration) *ExecStrategy
WithTimeout can be used to change the default startup timeout
type ExitStrategy ¶
type ExitStrategy struct {
// additional properties
PollInterval time.Duration
// contains filtered or unexported fields
}
ExitStrategy will wait until container exit
func ForExit ¶
func ForExit() *ExitStrategy
ForExit is the default construction for the fluid interface.
For Example:
wait. ForExit(). WithPollInterval(1 * time.Second)
func NewExitStrategy ¶
func NewExitStrategy() *ExitStrategy
NewExitStrategy constructs with polling interval of 100 milliseconds without timeout by default
func (*ExitStrategy) String ¶
func (ws *ExitStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*ExitStrategy) Timeout ¶
func (ws *ExitStrategy) Timeout() *time.Duration
func (*ExitStrategy) WaitUntilReady ¶
func (ws *ExitStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady implements Strategy.WaitUntilReady
func (*ExitStrategy) WithPollInterval ¶
func (ws *ExitStrategy) WithPollInterval(pollInterval time.Duration) *ExitStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*ExitStrategy) WithTimeout ¶
func (ws *ExitStrategy) WithTimeout(exitTimeout time.Duration) *ExitStrategy
WithTimeout can be used to change the default exit timeout
type FileStrategy ¶
type FileStrategy struct {
// contains filtered or unexported fields
}
FileStrategy waits for a file to exist in the container.
func ForFile ¶
func ForFile(file string) *FileStrategy
ForFile is a convenience method to assign FileStrategy
func NewFileStrategy ¶
func NewFileStrategy(file string) *FileStrategy
NewFileStrategy constructs an FileStrategy strategy.
func (*FileStrategy) String ¶
func (ws *FileStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*FileStrategy) Timeout ¶
func (ws *FileStrategy) Timeout() *time.Duration
Timeout returns the timeout for the strategy
func (*FileStrategy) WaitUntilReady ¶
func (ws *FileStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady waits until the file exists in the container and copies it to the target.
func (*FileStrategy) WithMatcher ¶
func (ws *FileStrategy) WithMatcher(matcher func(io.Reader) error) *FileStrategy
WithMatcher can be used to consume the file content. The matcher can return an errdefs.ErrNotFound to indicate that the file is not ready. Any other error will be considered a failure. Default: nil, will only wait for the file to exist.
func (*FileStrategy) WithPollInterval ¶
func (ws *FileStrategy) WithPollInterval(pollInterval time.Duration) *FileStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*FileStrategy) WithTimeout ¶
func (ws *FileStrategy) WithTimeout(startupTimeout time.Duration) *FileStrategy
WithTimeout can be used to change the default startup timeout
type HTTPStrategy ¶
type HTTPStrategy struct {
// additional properties
Port network.Port
Path string
StatusCodeMatcher func(status int) bool
ResponseMatcher func(body io.Reader) bool
UseTLS bool
AllowInsecure bool
TLSConfig *tls.Config // TLS config for HTTPS
Method string // http method
Body io.Reader // http request body
Headers map[string]string
ResponseHeadersMatcher func(headers http.Header) bool
PollInterval time.Duration
UserInfo *url.Userinfo
ForceIPv4LocalHost bool
// contains filtered or unexported fields
}
func ForHTTP ¶
func ForHTTP(path string) *HTTPStrategy
ForHTTP is a convenience method similar to Wait.java https://github.com/testcontainers/testcontainers-java/blob/1d85a3834bd937f80aad3a4cec249c027f31aeb4/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java
func NewHTTPStrategy ¶
func NewHTTPStrategy(path string) *HTTPStrategy
NewHTTPStrategy constructs an HTTP strategy waiting on port 80 and status code 200
func (*HTTPStrategy) String ¶
func (ws *HTTPStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*HTTPStrategy) Timeout ¶
func (ws *HTTPStrategy) Timeout() *time.Duration
func (*HTTPStrategy) WaitUntilReady ¶
func (ws *HTTPStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady implements Strategy.WaitUntilReady
func (*HTTPStrategy) WithAllowInsecure ¶
func (ws *HTTPStrategy) WithAllowInsecure(allowInsecure bool) *HTTPStrategy
func (*HTTPStrategy) WithBasicAuth ¶
func (ws *HTTPStrategy) WithBasicAuth(username, password string) *HTTPStrategy
func (*HTTPStrategy) WithBody ¶
func (ws *HTTPStrategy) WithBody(reqdata io.Reader) *HTTPStrategy
func (*HTTPStrategy) WithForcedIPv4LocalHost ¶
func (ws *HTTPStrategy) WithForcedIPv4LocalHost() *HTTPStrategy
WithForcedIPv4LocalHost forces usage of localhost to be ipv4 127.0.0.1 to avoid ipv6 docker bugs https://github.com/moby/moby/issues/42442 https://github.com/moby/moby/issues/42375
func (*HTTPStrategy) WithHeaders ¶
func (ws *HTTPStrategy) WithHeaders(headers map[string]string) *HTTPStrategy
func (*HTTPStrategy) WithMethod ¶
func (ws *HTTPStrategy) WithMethod(method string) *HTTPStrategy
func (*HTTPStrategy) WithPollInterval ¶
func (ws *HTTPStrategy) WithPollInterval(pollInterval time.Duration) *HTTPStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*HTTPStrategy) WithPort ¶
func (ws *HTTPStrategy) WithPort(port network.Port) *HTTPStrategy
WithPort set the port to wait for. Default is the lowest numbered port.
func (*HTTPStrategy) WithResponseHeadersMatcher ¶
func (ws *HTTPStrategy) WithResponseHeadersMatcher(matcher func(http.Header) bool) *HTTPStrategy
func (*HTTPStrategy) WithResponseMatcher ¶
func (ws *HTTPStrategy) WithResponseMatcher(matcher func(body io.Reader) bool) *HTTPStrategy
func (*HTTPStrategy) WithStatus ¶
func (ws *HTTPStrategy) WithStatus(status int) *HTTPStrategy
WithStatus uses [WithStatusCodeMatcher] with the given status code
func (*HTTPStrategy) WithStatusCodeMatcher ¶
func (ws *HTTPStrategy) WithStatusCodeMatcher(statusCodeMatcher func(status int) bool) *HTTPStrategy
WithStatusCodeMatcher sets the status code matcher to the given function
func (*HTTPStrategy) WithTLS ¶
func (ws *HTTPStrategy) WithTLS(useTLS bool, tlsconf ...*tls.Config) *HTTPStrategy
func (*HTTPStrategy) WithTimeout ¶
func (ws *HTTPStrategy) WithTimeout(timeout time.Duration) *HTTPStrategy
WithTimeout can be used to change the default startup timeout
type HealthStrategy ¶
type HealthStrategy struct {
// additional properties
PollInterval time.Duration
// contains filtered or unexported fields
}
HealthStrategy will wait until the container becomes healthy
func ForHealthCheck ¶
func ForHealthCheck() *HealthStrategy
ForHealthCheck is the default construction for the fluid interface.
For Example:
wait. ForHealthCheck(). WithPollInterval(1 * time.Second)
func NewHealthStrategy ¶
func NewHealthStrategy() *HealthStrategy
NewHealthStrategy constructs with polling interval of 100 milliseconds and startup timeout of 60 seconds by default
func (*HealthStrategy) String ¶
func (ws *HealthStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*HealthStrategy) Timeout ¶
func (ws *HealthStrategy) Timeout() *time.Duration
func (*HealthStrategy) WaitUntilReady ¶
func (ws *HealthStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady implements Strategy.WaitUntilReady
func (*HealthStrategy) WithPollInterval ¶
func (ws *HealthStrategy) WithPollInterval(pollInterval time.Duration) *HealthStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*HealthStrategy) WithTimeout ¶
func (ws *HealthStrategy) WithTimeout(startupTimeout time.Duration) *HealthStrategy
WithTimeout can be used to change the default startup timeout
type HostPortStrategy ¶
type HostPortStrategy struct {
// Port is a string containing port number and protocol in the format "80/tcp"
// which
Port network.Port
PollInterval time.Duration
// contains filtered or unexported fields
}
func ForExposedPort ¶
func ForExposedPort() *HostPortStrategy
ForExposedPort returns a host port strategy that waits for the first port to be exposed and bound internally the container.
func ForListeningPort ¶
func ForListeningPort(port network.Port) *HostPortStrategy
ForListeningPort returns a host port strategy that waits for the given port to be exposed and bound internally the container. Alias for `NewHostPortStrategy(port)`.
func ForMappedPort ¶
func ForMappedPort(port network.Port) *HostPortStrategy
ForMappedPort returns a host port strategy that waits for the given port to be mapped without accessing the port itself.
func NewHostPortStrategy ¶
func NewHostPortStrategy(port network.Port) *HostPortStrategy
NewHostPortStrategy constructs a default host port strategy that waits for the given port to be exposed. The default startup timeout is 60 seconds.
func (*HostPortStrategy) SkipExternalCheck ¶
func (hp *HostPortStrategy) SkipExternalCheck() *HostPortStrategy
SkipExternalCheck changes the host port strategy to skip the external check, which, if used with SkipInternalCheck, makes strategy waiting only for port mapping completion without accessing port.
func (*HostPortStrategy) SkipInternalCheck ¶
func (hp *HostPortStrategy) SkipInternalCheck() *HostPortStrategy
SkipInternalCheck changes the host port strategy to skip the internal check, which is useful when a shell is not available in the container or when the container doesn't bind the port internally until additional conditions are met.
func (*HostPortStrategy) String ¶
func (hp *HostPortStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*HostPortStrategy) Timeout ¶
func (hp *HostPortStrategy) Timeout() *time.Duration
func (*HostPortStrategy) WaitUntilReady ¶
func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady implements Strategy.WaitUntilReady
func (*HostPortStrategy) WithPollInterval ¶
func (hp *HostPortStrategy) WithPollInterval(pollInterval time.Duration) *HostPortStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*HostPortStrategy) WithTimeout ¶
func (hp *HostPortStrategy) WithTimeout(startupTimeout time.Duration) *HostPortStrategy
WithTimeout can be used to change the default startup timeout
type LogStrategy ¶
type LogStrategy struct {
// additional properties
Log string
IsRegexp bool
Occurrence int
PollInterval time.Duration
// contains filtered or unexported fields
}
LogStrategy will wait until a given log entry shows up in the docker logs
func ForLog ¶
func ForLog(log string) *LogStrategy
ForLog is the default construction for the fluid interface.
For Example:
wait.
ForLog("some text").
WithPollInterval(1 * time.Second)
func NewLogStrategy ¶
func NewLogStrategy(log string) *LogStrategy
NewLogStrategy constructs with polling interval of 100 milliseconds and startup timeout of 60 seconds by default
func (*LogStrategy) AsRegexp ¶
func (ws *LogStrategy) AsRegexp() *LogStrategy
AsRegexp can be used to change the default behavior of the log strategy to use regexp instead of plain text
func (*LogStrategy) String ¶
func (ws *LogStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*LogStrategy) Submatch ¶
func (ws *LogStrategy) Submatch(callback func(pattern string, matches [][][]byte) error) *LogStrategy
Submatch configures a function that will be called with the result of regexp.Regexp.FindAllSubmatch, allowing the caller to process the results. If the callback returns nil, the strategy will be considered successful. Returning a PermanentError will stop the wait and return an error, otherwise it will retry until the timeout is reached. [LogStrategy.Occurrence] is ignored if this option is set.
func (*LogStrategy) Timeout ¶
func (ws *LogStrategy) Timeout() *time.Duration
func (*LogStrategy) WaitUntilReady ¶
func (ws *LogStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady implements Strategy.WaitUntilReady
func (*LogStrategy) WithOccurrence ¶
func (ws *LogStrategy) WithOccurrence(o int) *LogStrategy
func (*LogStrategy) WithPollInterval ¶
func (ws *LogStrategy) WithPollInterval(pollInterval time.Duration) *LogStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*LogStrategy) WithTimeout ¶
func (ws *LogStrategy) WithTimeout(timeout time.Duration) *LogStrategy
WithTimeout can be used to change the default startup timeout
type MultiStrategy ¶
type MultiStrategy struct {
// additional properties
Strategies []Strategy
// contains filtered or unexported fields
}
func ForAll ¶
func ForAll(strategies ...Strategy) *MultiStrategy
func (*MultiStrategy) String ¶
func (ms *MultiStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*MultiStrategy) Timeout ¶
func (ms *MultiStrategy) Timeout() *time.Duration
func (*MultiStrategy) WaitUntilReady ¶
func (ms *MultiStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
func (*MultiStrategy) WithDeadline ¶
func (ms *MultiStrategy) WithDeadline(deadline time.Duration) *MultiStrategy
WithDeadline sets a time.Duration which limits all wait strategies
func (*MultiStrategy) WithStartupTimeoutDefault ¶
func (ms *MultiStrategy) WithStartupTimeoutDefault(timeout time.Duration) *MultiStrategy
WithStartupTimeoutDefault sets the default timeout for all inner wait strategies
type NopStrategy ¶
type NopStrategy struct {
// contains filtered or unexported fields
}
func ForNop ¶
func ForNop( waitUntilReady func(context.Context, StrategyTarget) error, ) *NopStrategy
func (*NopStrategy) String ¶
func (ws *NopStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*NopStrategy) Timeout ¶
func (ws *NopStrategy) Timeout() *time.Duration
func (*NopStrategy) WaitUntilReady ¶
func (ws *NopStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
func (*NopStrategy) WithTimeout ¶
func (ws *NopStrategy) WithTimeout(timeout time.Duration) *NopStrategy
type NopStrategyTarget ¶
type NopStrategyTarget struct {
ReaderCloser io.ReadCloser
ContainerState container.State
}
func (*NopStrategyTarget) CopyFromContainer ¶
func (st *NopStrategyTarget) CopyFromContainer(_ context.Context, _ string) (io.ReadCloser, error)
func (*NopStrategyTarget) Exec ¶
func (st *NopStrategyTarget) Exec(_ context.Context, _ []string, _ ...exec.ProcessOption) (int, io.Reader, error)
func (*NopStrategyTarget) Host ¶
func (st *NopStrategyTarget) Host(_ context.Context) (string, error)
func (*NopStrategyTarget) Inspect ¶
func (st *NopStrategyTarget) Inspect(_ context.Context) (client.ContainerInspectResult, error)
func (*NopStrategyTarget) Logger ¶
func (st *NopStrategyTarget) Logger() *slog.Logger
func (*NopStrategyTarget) Logs ¶
func (st *NopStrategyTarget) Logs(_ context.Context) (io.ReadCloser, error)
func (*NopStrategyTarget) MappedPort ¶
type PermanentError ¶
type PermanentError struct {
// contains filtered or unexported fields
}
PermanentError is a special error that will stop the wait and return an error.
func NewPermanentError ¶
func NewPermanentError(err error) *PermanentError
NewPermanentError creates a new PermanentError.
func (*PermanentError) Error ¶
func (e *PermanentError) Error() string
Error implements the error interface.
type Strategy ¶
type Strategy interface {
WaitUntilReady(context.Context, StrategyTarget) error
}
Strategy defines the basic interface for a Wait Strategy
type StrategyTarget ¶
type StrategyTarget interface {
Host(context.Context) (string, error)
Inspect(context.Context) (dockerclient.ContainerInspectResult, error)
MappedPort(context.Context, network.Port) (network.Port, error)
Logs(context.Context) (io.ReadCloser, error)
Exec(context.Context, []string, ...exec.ProcessOption) (int, io.Reader, error)
State(context.Context) (*container.State, error)
CopyFromContainer(ctx context.Context, filePath string) (io.ReadCloser, error)
Logger() *slog.Logger
}
type StrategyTimeout ¶
StrategyTimeout allows MultiStrategy to configure a Strategy's Timeout
type TLSStrategy ¶
type TLSStrategy struct {
// contains filtered or unexported fields
}
TLSStrategy is a strategy for handling TLS.
func ForTLSCert ¶
func ForTLSCert(certPEMFile, keyPEMFile string) *TLSStrategy
ForTLSCert returns a CertStrategy that will add a Certificate to the tls.Config constructed from PEM formatted certificate key file pair in the container.
func ForTLSRootCAs ¶
func ForTLSRootCAs(pemFiles ...string) *TLSStrategy
ForTLSRootCAs returns a CertStrategy that sets the root CAs for the tls.Config using the given PEM formatted files from the container.
func (*TLSStrategy) String ¶
func (ws *TLSStrategy) String() string
String returns a human-readable description of the wait strategy.
func (*TLSStrategy) TLSConfig ¶
func (ws *TLSStrategy) TLSConfig() *tls.Config
TLSConfig returns the TLS config once the strategy is ready. If the strategy is nil, it returns nil.
func (*TLSStrategy) WaitUntilReady ¶
func (ws *TLSStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
WaitUntilReady implements the Strategy interface. It waits for the CA, client cert and key files to be available in the container and uses them to setup the TLS config.
func (*TLSStrategy) WithCert ¶
func (ws *TLSStrategy) WithCert(certPEMFile, keyPEMFile string) *TLSStrategy
WithCert sets the tls.Config Certificates using the given files from the container.
func (*TLSStrategy) WithPollInterval ¶
func (ws *TLSStrategy) WithPollInterval(pollInterval time.Duration) *TLSStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds.
func (*TLSStrategy) WithRootCAs ¶
func (ws *TLSStrategy) WithRootCAs(files ...string) *TLSStrategy
WithRootCAs sets the root CAs for the tls.Config using the given files from the container.
func (*TLSStrategy) WithServerName ¶
func (ws *TLSStrategy) WithServerName(serverName string) *TLSStrategy
WithServerName sets the server for the tls.Config.
func (*TLSStrategy) WithTimeout ¶
func (ws *TLSStrategy) WithTimeout(startupTimeout time.Duration) *TLSStrategy
WithTimeout can be used to change the default startup timeout.
type VisitFunc ¶
VisitFunc is a function that visits a strategy node. If it returns ErrVisitStop, the walk stops. If it returns ErrVisitRemove, the current node is removed.