Skip to content

Commit 58d47e1

Browse files
committed
Merge branch 'main' into toxyproxy-module
* main: chore(deps): bump golang.org/x/crypto in /modules/aerospike (testcontainers#3105) chore(ci): run codeql on the modified modules (testcontainers#3103) docs: fix reference to container types in Run function (testcontainers#3102) chore(deps): bump github.com/golang-jwt/jwt/v5 in /modules/pulsar (testcontainers#3101) chore(pulsar): bump github.com/apache/pulsar-client-go from 0.10.0 to 0.14.0 (testcontainers#3100) chore(clickhouse): bump github.com/ClickHouse/clickhouse-go/v2 from 2.20.0 to 2.34.0 in /modules/clickhouse (testcontainers#3099) chore(deps): bump github/codeql-action from 3.28.13 to 3.28.15 (testcontainers#3097) chore(deps): bump golang.org/x/crypto from 0.31.0 to 0.37.0 (testcontainers#3098) feat(aerospike): add Aerospike module (testcontainers#3094)
2 parents e99d830 + 438cefe commit 58d47e1

Some content is hidden

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

133 files changed

+1348
-713
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ updates:
1515
- /
1616
- /examples/nginx
1717
- /modulegen
18+
- /modules/aerospike
1819
- /modules/arangodb
1920
- /modules/artemis
2021
- /modules/azure

.github/workflows/codeql.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,39 @@ permissions:
2424
contents: read
2525

2626
jobs:
27+
detect-modules:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
modules: ${{ steps.set-modified-modules.outputs.modules }}
31+
modules_count: ${{ steps.set-modified-modules-count.outputs.modules_count }}
32+
steps:
33+
- name: Check out code into the Go module directory
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
36+
- id: changed-files
37+
name: Get changed files
38+
uses: tj-actions/changed-files@823fcebdb31bb35fdf2229d9f769b400309430d0 # v46.0.3
39+
40+
- id: set-modified-modules
41+
name: Set all modified modules
42+
env:
43+
ALL_CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}"
44+
run: echo "modules=$(./scripts/changed-modules.sh)" >> $GITHUB_OUTPUT
45+
46+
- id: set-modified-modules-count
47+
name: Set all modified modules count
48+
run: echo "modules_count=$(echo ${{ toJSON(steps.set-modified-modules.outputs.modules) }} | jq '. | length')" >> $GITHUB_OUTPUT
49+
50+
- name: Print out the modules to be used
51+
run: |
52+
echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build"
53+
echo "${{ steps.set-modified-modules.outputs.modules }}"
54+
2755
analyze:
56+
# only run if there are modules to lint
57+
if: ${{ needs.detect-modules.outputs.modules_count > 0 }}
58+
needs:
59+
- detect-modules
2860
name: Analyze
2961
# Runner size impacts CodeQL analysis time. To learn more, please see:
3062
# - https://gh.io/recommended-hardware-resources-for-running-codeql
@@ -41,6 +73,7 @@ jobs:
4173
strategy:
4274
fail-fast: false
4375
matrix:
76+
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
4477
language: [ 'go', 'javascript']
4578
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
4679
# Use only 'java' to analyze code written in Java, Kotlin or both
@@ -53,7 +86,7 @@ jobs:
5386

5487
# Initializes the CodeQL tools for scanning.
5588
- name: Initialize CodeQL
56-
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
89+
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
5790
with:
5891
languages: ${{ matrix.language }}
5992
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -67,7 +100,9 @@ jobs:
67100
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
68101
# If this step fails, then you should remove it and run the build manually (see below)
69102
- name: Autobuild
70-
uses: github/codeql-action/autobuild@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
103+
uses: github/codeql-action/autobuild@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
104+
with:
105+
working-directory: "${{ matrix.module }}"
71106

72107
# ℹ️ Command-line programs to run using the OS shell.
73108
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -80,6 +115,6 @@ jobs:
80115
# ./location_of_script_within_repo/buildscript.sh
81116

82117
- name: Perform CodeQL Analysis
83-
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
118+
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
84119
with:
85120
category: "/language:${{matrix.language}}"

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ jobs:
5151

5252
# required for Code scanning alerts
5353
- name: "Upload SARIF results to code scanning"
54-
uses: github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
54+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
5555
with:
5656
sarif_file: results.sarif

docs/modules/aerospike.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Aerospike
2+
3+
Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
4+
5+
## Introduction
6+
7+
The Testcontainers module for Aerospike.
8+
9+
## Adding this module to your project dependencies
10+
11+
Please run the following command to add the Aerospike module to your Go dependencies:
12+
13+
```
14+
go get github.com/testcontainers/testcontainers-go/modules/aerospike
15+
```
16+
17+
## Usage example
18+
19+
<!--codeinclude-->
20+
[Creating a Aerospike container](../../modules/aerospike/examples_test.go) inside_block:runAerospikeContainer
21+
<!--/codeinclude-->
22+
23+
## Module Reference
24+
25+
### Run function
26+
27+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
28+
29+
The Aerospike module exposes one entrypoint function to create the Aerospike container, and this function receives three parameters:
30+
31+
```golang
32+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
33+
```
34+
35+
- `context.Context`, the Go context.
36+
- `string`, the Docker image to use.
37+
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.
38+
39+
### Container Options
40+
41+
When starting the Aerospike container, you can pass options in a variadic way to configure it.
42+
43+
#### Image
44+
45+
Use the second argument in the `Run` function to set a valid Docker image.
46+
In example: `Run(context.Background(), "aerospike/aerospike-server:latest")`.
47+
48+
{% include "../features/common_functional_options.md" %}
49+
50+
## Examples
51+
52+
### Aerospike Client
53+
54+
<!--codeinclude-->
55+
[Aerospike Client](../../modules/aerospike/examples_test.go) inside_block:usingClient
56+
<!--/codeinclude-->

docs/modules/azure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The Azure module exposes the following Go packages:
3737
The Azurite module exposes one entrypoint function to create the Azurite container, and this function receives three parameters:
3838

3939
```golang
40-
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*AzuriteContainer, error)
40+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
4141
```
4242

4343
- `context.Context`, the Go context.

docs/modules/dind.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ go get github.com/testcontainers/testcontainers-go/modules/dind
2929
The DinD module exposes one entrypoint function to create the DinD container, and this function receives three parameters:
3030

3131
```golang
32-
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*DinDContainer, error)
32+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
3333
```
3434

3535
- `context.Context`, the Go context.

docs/modules/etcd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ go get github.com/testcontainers/testcontainers-go/modules/etcd
2929
The etcd module exposes one entrypoint function to create the etcd container, and this function receives three parameters:
3030

3131
```golang
32-
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*etcdContainer, error)
32+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*EtcdContainer, error)
3333
```
3434

3535
- `context.Context`, the Go context.

docs/modules/pinecone.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ go get github.com/testcontainers/testcontainers-go/modules/pinecone
3232
The Pinecone module exposes one entrypoint function to create the Pinecone container, and this function receives three parameters:
3333

3434
```golang
35-
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*PineconeContainer, error)
35+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
3636
```
3737

3838
- `context.Context`, the Go context.

examples/nginx/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ require (
5858
go.opentelemetry.io/otel/metric v1.35.0 // indirect
5959
go.opentelemetry.io/otel/trace v1.35.0 // indirect
6060
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
61-
golang.org/x/crypto v0.35.0 // indirect
61+
golang.org/x/crypto v0.37.0 // indirect
6262
golang.org/x/net v0.36.0 // indirect
63-
golang.org/x/sys v0.31.0 // indirect
63+
golang.org/x/sys v0.32.0 // indirect
6464
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
6565
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
6666
gopkg.in/yaml.v3 v3.0.1 // indirect

examples/nginx/go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v8
124124
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
125125
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
126126
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
127-
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
128-
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
127+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
128+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
129129
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
130130
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
131131
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -146,14 +146,14 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
146146
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
147147
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
148148
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
149-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
150-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
151-
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
152-
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
149+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
150+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
151+
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
152+
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
153153
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
154154
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
155-
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
156-
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
155+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
156+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
157157
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
158158
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
159159
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ require (
1818
github.com/opencontainers/image-spec v1.1.1
1919
github.com/shirou/gopsutil/v4 v4.25.1
2020
github.com/stretchr/testify v1.10.0
21-
golang.org/x/crypto v0.31.0
22-
golang.org/x/sys v0.31.0
21+
golang.org/x/crypto v0.37.0
22+
golang.org/x/sys v0.32.0
2323
)
2424

2525
require (

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v8
124124
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
125125
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
126126
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
127-
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
128-
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
127+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
128+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
129129
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
130130
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
131131
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -146,14 +146,14 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
146146
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
147147
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
148148
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
149-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
150-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
151-
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
152-
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
149+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
150+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
151+
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
152+
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
153153
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
154154
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
155-
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
156-
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
155+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
156+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
157157
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
158158
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
159159
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ nav:
6868
- Walk: features/wait/walk.md
6969
- Modules:
7070
- modules/index.md
71+
- modules/aerospike.md
7172
- modules/arangodb.md
7273
- modules/artemis.md
7374
- modules/azure.md

modulegen/_template/module.md.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ go get github.com/testcontainers/testcontainers-go/{{ ParentDir }}/{{ $lower }}
2929
The {{ $title }} module exposes one entrypoint function to create the {{ $title }} container, and this function receives three parameters:
3030

3131
```golang
32-
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*{{ $title }}Container, error)
32+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
3333
```
3434

3535
- `context.Context`, the Go context.

modulegen/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func assertModuleDocContent(t *testing.T, module context.TestcontainersModule, m
372372
require.Equal(t, "[Creating a "+title+" container](../../"+module.ParentDir()+"/"+lower+"/examples_test.go) inside_block:Example"+entrypoint, data[19])
373373
require.Equal(t, "<!--/codeinclude-->", data[20])
374374
require.Equal(t, "The "+title+" module exposes one entrypoint function to create the "+title+" container, and this function receives three parameters:", data[28])
375-
require.True(t, strings.HasSuffix(data[31], "(*"+title+"Container, error)"))
375+
require.True(t, strings.HasSuffix(data[31], "(*Container, error)"))
376376
require.Equal(t, "Use the second argument in the `Run` function to set a valid Docker image.", data[44])
377377
require.Equal(t, "In example: `Run(context.Background(), \""+module.Image+"\")`.", data[45])
378378
}

modules/aerospike/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include ../../commons-test.mk
2+
3+
.PHONY: test
4+
test:
5+
$(MAKE) test-aerospike

modules/aerospike/aerospike.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package aerospike
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"time"
7+
8+
"github.com/testcontainers/testcontainers-go"
9+
"github.com/testcontainers/testcontainers-go/wait"
10+
)
11+
12+
const (
13+
// port is the port used for client connections
14+
port = "3000/tcp"
15+
// fabricPort is the port used for Intra-cluster communication port.
16+
// Replica writes, migrations, and other node-to-node communications use the Fabric port.
17+
fabricPort = "3001/tcp"
18+
// heartbeatPort is the port used for heartbeat communication
19+
// between nodes in the Aerospike cluster
20+
heartbeatPort = "3002/tcp"
21+
// infoPort is the port used for info commands
22+
infoPort = "3003/tcp"
23+
)
24+
25+
// Container is the Aerospike container type used in the module
26+
type Container struct {
27+
testcontainers.Container
28+
}
29+
30+
// Run creates an instance of the Aerospike container type
31+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
32+
req := testcontainers.ContainerRequest{
33+
Image: img,
34+
ExposedPorts: []string{port, fabricPort, heartbeatPort, infoPort},
35+
Env: map[string]string{
36+
"AEROSPIKE_CONFIG_FILE": "/etc/aerospike/aerospike.conf",
37+
},
38+
WaitingFor: wait.ForAll(
39+
wait.ForLog("migrations: complete"),
40+
wait.ForListeningPort(port).WithStartupTimeout(10*time.Second),
41+
wait.ForListeningPort(fabricPort).WithStartupTimeout(10*time.Second),
42+
wait.ForListeningPort(heartbeatPort).WithStartupTimeout(10*time.Second),
43+
),
44+
}
45+
46+
genericContainerReq := testcontainers.GenericContainerRequest{
47+
ContainerRequest: req,
48+
Started: true,
49+
}
50+
51+
for _, opt := range opts {
52+
if err := opt.Customize(&genericContainerReq); err != nil {
53+
return nil, fmt.Errorf("customize: %w", err)
54+
}
55+
}
56+
57+
container, err := testcontainers.GenericContainer(ctx, genericContainerReq)
58+
var c *Container
59+
if container != nil {
60+
c = &Container{Container: container}
61+
}
62+
63+
if err != nil {
64+
return c, fmt.Errorf("generic container: %w", err)
65+
}
66+
67+
return c, nil
68+
}

0 commit comments

Comments
 (0)