Skip to content

Commit 6403e18

Browse files
authored
Merge branch 'main' into ms/script-helper-fn
2 parents 0667479 + 79e21bb commit 6403e18

File tree

118 files changed

+726
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+726
-359
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/go
33
{
44
"name": "Go",
5-
"image": "mcr.microsoft.com/devcontainers/go:1.22-bookworm",
5+
"image": "mcr.microsoft.com/devcontainers/go:1.23-bookworm",
66

77
// Features to add to the dev container. More info: https://containers.dev/features.
88
// "features": {},

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ branches:
183183
# Required. Require branches to be up to date before merging.
184184
strict: true
185185
# Required. The list of status checks to require in order to merge into this branch
186-
contexts: ["test (1.x, ubuntu-latest) / ./ubuntu-latest/1.x"]
186+
contexts: ["test (1.24.x) / test: /1.24.x"]
187187
# Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
188188
enforce_admins: false
189189
# Prevent merge commits from being pushed to matching branches

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
# We don't want to fail the build the soonest but identify which modules passed and failed.
6262
fail-fast: false
6363
matrix:
64-
go-version: [1.22.x, 1.x]
64+
go-version: [1.23.x, 1.24.x]
6565
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
6666
uses: ./.github/workflows/ci-test-go.yml
6767
with:
@@ -82,7 +82,7 @@ jobs:
8282
name: "Test with reaper off"
8383
strategy:
8484
matrix:
85-
go-version: [1.22.x, 1.x]
85+
go-version: [1.23.x, 1.24.x]
8686
uses: ./.github/workflows/ci-test-go.yml
8787
with:
8888
go-version: ${{ matrix.go-version }}
@@ -102,7 +102,7 @@ jobs:
102102
name: "Test with Rootless Docker"
103103
strategy:
104104
matrix:
105-
go-version: [1.22.x, 1.x]
105+
go-version: [1.23.x, 1.24.x]
106106
uses: ./.github/workflows/ci-test-go.yml
107107
with:
108108
go-version: ${{ matrix.go-version }}

container.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
tcexec "github.com/testcontainers/testcontainers-go/exec"
2525
"github.com/testcontainers/testcontainers-go/internal/core"
26+
"github.com/testcontainers/testcontainers-go/log"
2627
"github.com/testcontainers/testcontainers-go/wait"
2728
)
2829

@@ -469,7 +470,7 @@ func (c *ContainerRequest) BuildOptions() (types.ImageBuildOptions, error) {
469470
}
470471

471472
if modifiedTag != tag {
472-
Logger.Printf("✍🏼 Replacing image with %s. From: %s to %s\n", is.Description(), tag, modifiedTag)
473+
log.Printf("✍🏼 Replacing image with %s. From: %s to %s\n", is.Description(), tag, modifiedTag)
473474
tag = modifiedTag
474475
}
475476
}

container_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"io"
10-
"log"
1110
"testing"
1211
"time"
1312

@@ -17,6 +16,7 @@ import (
1716
"github.com/stretchr/testify/require"
1817

1918
"github.com/testcontainers/testcontainers-go"
19+
"github.com/testcontainers/testcontainers-go/log"
2020
"github.com/testcontainers/testcontainers-go/wait"
2121
)
2222

docker.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
tcexec "github.com/testcontainers/testcontainers-go/exec"
3737
"github.com/testcontainers/testcontainers-go/internal/config"
3838
"github.com/testcontainers/testcontainers-go/internal/core"
39+
"github.com/testcontainers/testcontainers-go/log"
3940
"github.com/testcontainers/testcontainers-go/wait"
4041
)
4142

@@ -89,14 +90,14 @@ type DockerContainer struct {
8990
logProductionCtx context.Context
9091

9192
logProductionTimeout *time.Duration
92-
logger Logging
93+
logger log.Logger
9394
lifecycleHooks []ContainerLifecycleHooks
9495

9596
healthStatus string // container health status, will default to healthStatusNone if no healthcheck is present
9697
}
9798

9899
// SetLogger sets the logger for the container
99-
func (c *DockerContainer) SetLogger(logger Logging) {
100+
func (c *DockerContainer) SetLogger(logger log.Logger) {
100101
c.logger = logger
101102
}
102103

@@ -817,7 +818,7 @@ func (c *DockerContainer) copyLogsTimeout(stdout, stderr io.Writer, options *con
817818
// Timeout or client connection closed, retry.
818819
default:
819820
// Unexpected error, retry.
820-
Logger.Printf("Unexpected error reading logs: %v", err)
821+
c.logger.Printf("Unexpected error reading logs: %v", err)
821822
}
822823

823824
// Retry from the last log received.

docker_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/testcontainers/testcontainers-go/internal"
1515
"github.com/testcontainers/testcontainers-go/internal/core"
16+
"github.com/testcontainers/testcontainers-go/log"
1617
)
1718

1819
// DockerClient is a wrapper around the docker client that is used by testcontainers-go.
@@ -73,7 +74,7 @@ func (c *DockerClient) Info(ctx context.Context) (system.Info, error) {
7374
}
7475
}
7576

76-
Logger.Printf(infoMessage, packagePath,
77+
log.Printf(infoMessage, packagePath,
7778
dockerInfo.ServerVersion,
7879
c.Client.ClientVersion(),
7980
dockerInfo.OperatingSystem, dockerInfo.MemTotal/1024/1024,

docker_mounts.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package testcontainers
22

3-
import "github.com/docker/docker/api/types/mount"
3+
import (
4+
"github.com/docker/docker/api/types/mount"
5+
6+
"github.com/testcontainers/testcontainers-go/log"
7+
)
48

59
var mountTypeMapping = map[MountType]mount.Type{
610
MountTypeBind: mount.TypeBind, // Deprecated, it will be removed in a future release
@@ -115,7 +119,7 @@ func mapToDockerMounts(containerMounts ContainerMounts) []mount.Mount {
115119
case TmpfsMounter:
116120
containerMount.TmpfsOptions = typedMounter.GetTmpfsOptions()
117121
case BindMounter:
118-
Logger.Printf("Mount type %s is not supported by Testcontainers for Go", m.Source.Type())
122+
log.Printf("Mount type %s is not supported by Testcontainers for Go", m.Source.Type())
119123
default:
120124
// The provided source type has no custom options
121125
}

docker_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"io"
9-
"log"
109
"math/rand"
1110
"net/http"
1211
"os"
@@ -26,6 +25,7 @@ import (
2625
"github.com/stretchr/testify/require"
2726

2827
"github.com/testcontainers/testcontainers-go/internal/core"
28+
"github.com/testcontainers/testcontainers-go/log"
2929
"github.com/testcontainers/testcontainers-go/wait"
3030
)
3131

@@ -1809,7 +1809,7 @@ func TestContainerWithNoUserID(t *testing.T) {
18091809
func TestGetGatewayIP(t *testing.T) {
18101810
// When using docker compose with DinD mode, and using host port or http wait strategy
18111811
// It's need to invoke GetGatewayIP for get the host
1812-
provider, err := providerType.GetProvider(WithLogger(TestLogger(t)))
1812+
provider, err := providerType.GetProvider(WithLogger(log.TestLogger(t)))
18131813
require.NoError(t, err)
18141814
defer provider.Close()
18151815

@@ -1898,7 +1898,7 @@ func assertExtractedFiles(t *testing.T, ctx context.Context, container Container
18981898

18991899
func TestDockerProviderFindContainerByName(t *testing.T) {
19001900
ctx := context.Background()
1901-
provider, err := NewDockerProvider(WithLogger(TestLogger(t)))
1901+
provider, err := NewDockerProvider(WithLogger(log.TestLogger(t)))
19021902
require.NoError(t, err)
19031903
defer provider.Close()
19041904

docs/features/common_functional_options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ If you need to either pass logger to a container, you can use `testcontainers.Wi
6262
!!!info
6363
Consider calling this before other "With" functions as these may generate logs.
6464

65-
In this example we also use `TestLogger` which writes to the passed in `testing.TB` using `Logf`.
65+
In this example we also use the testcontainers-go `log.TestLogger`, which writes to the passed in `testing.TB` using `Logf`.
6666
The result is that we capture all logging from the container into the test context meaning its
6767
hidden behind `go test -v` and is associated with the relevant test, providing the user with
6868
useful context instead of appearing out of band.
6969

7070
```golang
7171
func TestHandler(t *testing.T) {
72-
logger := TestLogger(t)
72+
logger := log.TestLogger(t)
7373
ctr, err := postgresModule.Run(ctx, "postgres:15-alpine", testcontainers.WithLogger(logger))
7474
CleanupContainer(t, ctr)
7575
require.NoError(t, err)

0 commit comments

Comments
 (0)