build(deps): bump github.com/testcontainers/testcontainers-go
Bumps [github.com/testcontainers/testcontainers-go](https://github.com/testcontainers/testcontainers-go) from 0.39.0 to 0.40.0. - [Release notes](https://github.com/testcontainers/testcontainers-go/releases) - [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.39.0...v0.40.0) --- updated-dependencies: - dependency-name: github.com/testcontainers/testcontainers-go dependency-version: 0.40.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
d352d91210
commit
3e81d1f1d8
+25
@@ -3,7 +3,9 @@ package wait
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -51,6 +53,29 @@ func (ms *MultiStrategy) Timeout() *time.Duration {
|
||||
return ms.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ms *MultiStrategy) String() string {
|
||||
if len(ms.Strategies) == 0 {
|
||||
return "all of: (none)"
|
||||
}
|
||||
|
||||
var strategies []string
|
||||
for _, strategy := range ms.Strategies {
|
||||
if strategy == nil || reflect.ValueOf(strategy).IsNil() {
|
||||
continue
|
||||
}
|
||||
if s, ok := strategy.(fmt.Stringer); ok {
|
||||
strategies = append(strategies, s.String())
|
||||
} else {
|
||||
strategies = append(strategies, fmt.Sprintf("%T", strategy))
|
||||
}
|
||||
}
|
||||
|
||||
// Always include "all of:" prefix to make it clear this is a MultiStrategy
|
||||
// even when there's only one strategy after filtering out nils
|
||||
return "all of: [" + strings.Join(strategies, ", ") + "]"
|
||||
}
|
||||
|
||||
func (ms *MultiStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
var cancel context.CancelFunc
|
||||
if ms.deadline != nil {
|
||||
|
||||
+17
@@ -2,6 +2,7 @@ package wait
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
@@ -76,6 +77,22 @@ func (ws *ExecStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *ExecStrategy) String() string {
|
||||
if len(ws.cmd) == 0 {
|
||||
return "exec command"
|
||||
}
|
||||
// Only show the command name and argument count to avoid exposing sensitive data
|
||||
argCount := len(ws.cmd) - 1
|
||||
if argCount == 0 {
|
||||
return fmt.Sprintf("exec command %q", ws.cmd[0])
|
||||
}
|
||||
if argCount == 1 {
|
||||
return fmt.Sprintf("exec command %q with 1 argument", ws.cmd[0])
|
||||
}
|
||||
return fmt.Sprintf("exec command %q with %d arguments", ws.cmd[0], argCount)
|
||||
}
|
||||
|
||||
func (ws *ExecStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
timeout := defaultStartupTimeout()
|
||||
if ws.timeout != nil {
|
||||
|
||||
+5
@@ -59,6 +59,11 @@ func (ws *ExitStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *ExitStrategy) String() string {
|
||||
return "container to exit"
|
||||
}
|
||||
|
||||
// WaitUntilReady implements Strategy.WaitUntilReady
|
||||
func (ws *ExitStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
if ws.timeout != nil {
|
||||
|
||||
+8
@@ -61,6 +61,14 @@ func (ws *FileStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *FileStrategy) String() string {
|
||||
if ws.matcher != nil {
|
||||
return fmt.Sprintf("file %q to exist and match condition", ws.file)
|
||||
}
|
||||
return fmt.Sprintf("file %q to exist", ws.file)
|
||||
}
|
||||
|
||||
// WaitUntilReady waits until the file exists in the container and copies it to the target.
|
||||
func (ws *FileStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
timeout := defaultStartupTimeout()
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ func (ws *HealthStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *HealthStrategy) String() string {
|
||||
return "container to become healthy"
|
||||
}
|
||||
|
||||
// WaitUntilReady implements Strategy.WaitUntilReady
|
||||
func (ws *HealthStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
timeout := defaultStartupTimeout()
|
||||
|
||||
+22
@@ -114,6 +114,28 @@ func (hp *HostPortStrategy) Timeout() *time.Duration {
|
||||
return hp.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (hp *HostPortStrategy) String() string {
|
||||
port := "first exposed port"
|
||||
if hp.Port != "" {
|
||||
port = fmt.Sprintf("port %s", hp.Port)
|
||||
}
|
||||
|
||||
var checks string
|
||||
switch {
|
||||
case hp.skipInternalCheck && hp.skipExternalCheck:
|
||||
checks = " to be mapped"
|
||||
case hp.skipInternalCheck:
|
||||
checks = " to be accessible externally"
|
||||
case hp.skipExternalCheck:
|
||||
checks = " to be listening internally"
|
||||
default:
|
||||
checks = " to be listening"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%s", port, checks)
|
||||
}
|
||||
|
||||
// detectInternalPort returns the lowest internal port that is currently bound.
|
||||
// If no internal port is found, it returns the zero nat.Port value which
|
||||
// can be checked against an empty string.
|
||||
|
||||
+15
@@ -154,6 +154,21 @@ func (ws *HTTPStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *HTTPStrategy) String() string {
|
||||
proto := "HTTP"
|
||||
if ws.UseTLS {
|
||||
proto = "HTTPS"
|
||||
}
|
||||
|
||||
port := "default"
|
||||
if ws.Port != "" {
|
||||
port = ws.Port.Port()
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s %s request on port %s path %q", proto, ws.Method, port, ws.Path)
|
||||
}
|
||||
|
||||
// WaitUntilReady implements Strategy.WaitUntilReady
|
||||
func (ws *HTTPStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
timeout := defaultStartupTimeout()
|
||||
|
||||
+15
@@ -123,6 +123,21 @@ func (ws *LogStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *LogStrategy) String() string {
|
||||
logType := "log message"
|
||||
if ws.IsRegexp {
|
||||
logType = "log pattern"
|
||||
}
|
||||
|
||||
occurrence := ""
|
||||
if ws.Occurrence > 1 {
|
||||
occurrence = fmt.Sprintf(" (occurrence: %d)", ws.Occurrence)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s %q%s", logType, ws.Log, occurrence)
|
||||
}
|
||||
|
||||
// WaitUntilReady implements Strategy.WaitUntilReady
|
||||
func (ws *LogStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error {
|
||||
timeout := defaultStartupTimeout()
|
||||
|
||||
+5
@@ -33,6 +33,11 @@ func (ws *NopStrategy) Timeout() *time.Duration {
|
||||
return ws.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *NopStrategy) String() string {
|
||||
return "custom wait condition"
|
||||
}
|
||||
|
||||
func (ws *NopStrategy) WithStartupTimeout(timeout time.Duration) *NopStrategy {
|
||||
ws.timeout = &timeout
|
||||
return ws
|
||||
|
||||
+15
@@ -61,6 +61,21 @@ func (w *waitForSQL) Timeout() *time.Duration {
|
||||
return w.timeout
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (w *waitForSQL) String() string {
|
||||
port := "default"
|
||||
if w.Port != "" {
|
||||
port = w.Port.Port()
|
||||
}
|
||||
|
||||
query := ""
|
||||
if w.query != defaultForSQLQuery {
|
||||
query = fmt.Sprintf(" with query %q", w.query)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("SQL database on port %s using driver %q%s", port, w.Driver, query)
|
||||
}
|
||||
|
||||
// WaitUntilReady repeatedly tries to run "SELECT 1" or user defined query on the given port using sql and driver.
|
||||
//
|
||||
// If it doesn't succeed until the timeout value which defaults to 60 seconds, it will return an error.
|
||||
|
||||
+20
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -99,6 +100,25 @@ func (ws *TLSStrategy) TLSConfig() *tls.Config {
|
||||
return ws.tlsConfig
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the wait strategy.
|
||||
func (ws *TLSStrategy) String() string {
|
||||
var parts []string
|
||||
|
||||
if len(ws.rootFiles) > 0 {
|
||||
parts = append(parts, fmt.Sprintf("root CAs %v", ws.rootFiles))
|
||||
}
|
||||
|
||||
if ws.certFiles != nil {
|
||||
parts = append(parts, fmt.Sprintf("cert %q and key %q", ws.certFiles.certPEMFile, ws.certFiles.keyPEMFile))
|
||||
}
|
||||
|
||||
if len(parts) == 0 {
|
||||
return "TLS certificates"
|
||||
}
|
||||
|
||||
return strings.Join(parts, " and ")
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user