Skip to content

Commit 4c44b97

Browse files
committed
Merge branch 'main' into catinapoke/main
* main: docs: refine heading badges in README (testcontainers#2770) feat(wait): for file (testcontainers#2731) feat(compose): select services via profiles (testcontainers#2758) chore(deps): bump mkdocs-markdownextradata-plugin from 0.2.5 to 0.2.6 (testcontainers#2761) fix: update template too (testcontainers#2763) chore(deps): bump actions/checkout from 4.1.1 to 4.1.7 (testcontainers#2762) chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.2.2 (testcontainers#2760) fix: check if the discovered docker socket responds (testcontainers#2741) Upgrade milvus-io/milvus-sdk-go to avoid checksum mismatch. (testcontainers#2753) Fix trailing slash on Image Prefix (testcontainers#2747) chore: use new testcontainers/ryuk:0.9.0 image (testcontainers#2750)
2 parents d669bfb + 553afd3 commit 4c44b97

Some content is hidden

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

50 files changed

+1301
-239
lines changed

.github/workflows/ci-test-go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
run: sudo rm -rf /var/run/docker.sock
6363

6464
- name: Check out code into the Go module directory
65-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
65+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
6666

6767
- name: Set up Go
6868
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5

.github/workflows/ci-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
})
2525
2626
- name: Checkout
27-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
27+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2828
with:
2929
token: ${{ secrets.GITHUB_TOKEN }}
3030
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
runs-on: ubuntu-latest
130130
steps:
131131
- name: Check out code into the Go module directory
132-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
132+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
133133
with:
134134
# Disabling shallow clone is recommended for improving relevancy of reporting
135135
fetch-depth: 0

.github/workflows/codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
steps:
5151
- name: Checkout repository
52-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
52+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
5353

5454
# Initializes the CodeQL tools for scanning.
5555
- name: Initialize CodeQL

.github/workflows/docker-moby-latest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: sudo rm -rf /var/run/docker.sock
2828

2929
- name: Check out code into the Go module directory
30-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
30+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
3131

3232
- name: Set up Go
3333
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5

.github/workflows/scorecards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: "Checkout code"
23-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
23+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
2424
with:
2525
persist-credentials: false
2626

.mockery.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
quiet: True
2+
disable-version-string: True
3+
with-expecter: True
4+
mockname: "mock{{.InterfaceName}}"
5+
filename: "{{ .InterfaceName | lower }}_mock_test.go"
6+
outpkg: "{{.PackageName}}_test"
7+
dir: "{{.InterfaceDir}}"
8+
packages:
9+
github.com/testcontainers/testcontainers-go/wait:
10+
interfaces:
11+
StrategyTarget:

Pipfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ verify_ssl = true
88
[packages]
99
mkdocs = "==1.5.3"
1010
mkdocs-codeinclude-plugin = "==0.2.1"
11-
mkdocs-include-markdown-plugin = "==6.2.1"
11+
mkdocs-include-markdown-plugin = "==6.2.2"
1212
mkdocs-material = "==9.5.18"
13-
mkdocs-markdownextradata-plugin = "==0.2.5"
13+
mkdocs-markdownextradata-plugin = "==0.2.6"
1414

1515
[requires]
1616
python_version = "3.8"

Pipfile.lock

+114-108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
# Testcontainers
22

3-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=141451032&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs)
4-
5-
**Builds**
6-
73
[![Main pipeline](https://github.com/testcontainers/testcontainers-go/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/testcontainers/testcontainers-go/actions/workflows/ci.yml)
8-
9-
**Documentation**
10-
114
[![GoDoc Reference](https://pkg.go.dev/badge/github.com/testcontainers/testcontainers-go.svg)](https://pkg.go.dev/github.com/testcontainers/testcontainers-go)
12-
13-
**Social**
14-
15-
[![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack)](https://testcontainers.slack.com/)
16-
17-
**Code quality**
18-
195
[![Go Report Card](https://goreportcard.com/badge/github.com/testcontainers/testcontainers-go)](https://goreportcard.com/report/github.com/testcontainers/testcontainers-go)
206
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=testcontainers_testcontainers-go&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=testcontainers_testcontainers-go)
7+
[![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/testcontainers/testcontainers-go/blob/main/LICENSE)
218

22-
**License**
9+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=141451032&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs)
2310

24-
[![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/testcontainers/testcontainers-go/blob/main/LICENSE)
11+
[![Join our Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack)](https://testcontainers.slack.com/)
2512

2613
_Testcontainers for Go_ is a Go package that makes it simple to create and clean up container-based dependencies for
2714
automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers

docker_client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func (c *DockerClient) Info(ctx context.Context) (system.Info, error) {
7979
dockerInfo.OperatingSystem, dockerInfo.MemTotal/1024/1024,
8080
infoLabels,
8181
internal.Version,
82-
core.ExtractDockerHost(ctx),
83-
core.ExtractDockerSocket(ctx),
82+
core.MustExtractDockerHost(ctx),
83+
core.MustExtractDockerSocket(ctx),
8484
core.SessionID(),
8585
core.ProcessID(),
8686
)

docker_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -2280,3 +2280,30 @@ func TestDockerProvider_attemptToPullImage_retries(t *testing.T) {
22802280
})
22812281
}
22822282
}
2283+
2284+
func TestCustomPrefixTrailingSlashIsProperlyRemovedIfPresent(t *testing.T) {
2285+
hubPrefixWithTrailingSlash := "public.ecr.aws/"
2286+
dockerImage := "amazonlinux/amazonlinux:2023"
2287+
2288+
ctx := context.Background()
2289+
req := ContainerRequest{
2290+
Image: dockerImage,
2291+
ImageSubstitutors: []ImageSubstitutor{newPrependHubRegistry(hubPrefixWithTrailingSlash)},
2292+
}
2293+
2294+
c, err := GenericContainer(ctx, GenericContainerRequest{
2295+
ContainerRequest: req,
2296+
Started: true,
2297+
})
2298+
if err != nil {
2299+
t.Fatal(err)
2300+
}
2301+
defer func() {
2302+
terminateContainerOnEnd(t, ctx, c)
2303+
}()
2304+
2305+
// enforce the concrete type, as GenericContainer returns an interface,
2306+
// which will be changed in future implementations of the library
2307+
dockerContainer := c.(*DockerContainer)
2308+
assert.Equal(t, fmt.Sprintf("%s%s", hubPrefixWithTrailingSlash, dockerImage), dockerContainer.Image)
2309+
}

docs/features/configuration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ See [Docker environment variables](https://docs.docker.com/engine/reference/comm
8585
3. `${HOME}/.docker/desktop/docker.sock`.
8686
4. `/run/user/${UID}/docker.sock`, where `${UID}` is the user ID of the current user.
8787

88-
7. The default Docker socket including schema will be returned if none of the above are set.
88+
7. The library panics if none of the above are set, meaning that the Docker host was not detected.
8989

9090
## Docker socket path detection
9191

@@ -109,4 +109,4 @@ Path to Docker's socket. Used by Ryuk, Docker Compose, and a few other container
109109

110110
6. Else, the default location of the docker socket is used: `/var/run/docker.sock`
111111

112-
In any case, if the docker socket schema is `tcp://`, the default docker socket path will be returned.
112+
The library panics if the Docker host cannot be discovered.

docs/features/wait/file.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# File Wait Strategy
2+
3+
File Wait Strategy waits for a file to exist in the container, and allows to set the following conditions:
4+
5+
- the file to wait for.
6+
- a matcher which reads the file content, no-op if nil or not set.
7+
- the startup timeout to be used in seconds, default is 60 seconds.
8+
- the poll interval to be used in milliseconds, default is 100 milliseconds.
9+
10+
## Waiting for file to exist and extract the content
11+
12+
<!--codeinclude-->
13+
[Waiting for file to exist and extract the content](../../../wait/file_test.go) inside_block:waitForFileWithMatcher
14+
<!--/codeinclude-->

docs/features/wait/introduction.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Below you can find a list of the available wait strategies that you can use:
88

99
- [Exec](./exec.md)
1010
- [Exit](./exit.md)
11+
- [File](./file.md)
1112
- [Health](./health.md)
1213
- [HostPort](./host_port.md)
1314
- [HTTP](./http.md)

generic.go

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"strings"
78
"sync"
89

910
"github.com/testcontainers/testcontainers-go/internal/core"
@@ -74,6 +75,14 @@ func GenericContainer(ctx context.Context, req GenericContainerRequest) (Contain
7475
}
7576
if err != nil {
7677
// At this point `c` might not be nil. Give the caller an opportunity to call Destroy on the container.
78+
// TODO: Remove this debugging.
79+
if strings.Contains(err.Error(), "toomanyrequests") {
80+
// Debugging information for rate limiting.
81+
cfg, err := getDockerConfig()
82+
if err == nil {
83+
fmt.Printf("XXX: too many requests: %+v", cfg)
84+
}
85+
}
7786
return c, fmt.Errorf("create container: %w", err)
7887
}
7988

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ require (
4747
github.com/rogpeppe/go-internal v1.8.1 // indirect
4848
github.com/shoenig/go-m1cpu v0.1.6 // indirect
4949
github.com/sirupsen/logrus v1.9.3 // indirect
50+
github.com/stretchr/objx v0.5.2 // indirect
5051
github.com/tklauser/go-sysconf v0.3.12 // indirect
5152
github.com/tklauser/numcpus v0.6.1 // indirect
5253
github.com/yusufpapurcu/wmi v1.2.3 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
102102
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
103103
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
104104
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
105+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
106+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
105107
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
106108
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
107109
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=

image_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestImageList(t *testing.T) {
13-
t.Setenv("DOCKER_HOST", core.ExtractDockerHost(context.Background()))
13+
t.Setenv("DOCKER_HOST", core.MustExtractDockerHost(context.Background()))
1414

1515
provider, err := ProviderDocker.GetProvider()
1616
if err != nil {
@@ -54,7 +54,7 @@ func TestImageList(t *testing.T) {
5454
}
5555

5656
func TestSaveImages(t *testing.T) {
57-
t.Setenv("DOCKER_HOST", core.ExtractDockerHost(context.Background()))
57+
t.Setenv("DOCKER_HOST", core.MustExtractDockerHost(context.Background()))
5858

5959
provider, err := ProviderDocker.GetProvider()
6060
if err != nil {

internal/config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/magiconair/properties"
1212
)
1313

14-
const ReaperDefaultImage = "testcontainers/ryuk:0.8.1"
14+
const ReaperDefaultImage = "testcontainers/ryuk:0.9.0"
1515

1616
var (
1717
tcConfig Config

internal/core/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func NewClient(ctx context.Context, ops ...client.Opt) (*client.Client, error) {
1515
tcConfig := config.Read()
1616

17-
dockerHost := ExtractDockerHost(ctx)
17+
dockerHost := MustExtractDockerHost(ctx)
1818

1919
opts := []client.Opt{client.FromEnv, client.WithAPIVersionNegotiation()}
2020
if dockerHost != "" {

0 commit comments

Comments
 (0)