Skip to content

Commit 928b200

Browse files
authored
chore(aerospike): use Run function (#3311)
1 parent 9f0e4cd commit 928b200

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

modules/aerospike/aerospike.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,29 @@ type Container struct {
2929

3030
// Run creates an instance of the Aerospike container type
3131
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{
32+
moduleOpts := []testcontainers.ContainerCustomizer{
33+
testcontainers.WithExposedPorts(port, fabricPort, heartbeatPort, infoPort),
34+
testcontainers.WithEnv(map[string]string{
3635
"AEROSPIKE_CONFIG_FILE": "/etc/aerospike/aerospike.conf",
37-
},
38-
WaitingFor: wait.ForAll(
36+
}),
37+
testcontainers.WithWaitStrategy(wait.ForAll(
3938
wait.ForLog("migrations: complete"),
4039
wait.ForListeningPort(port).WithStartupTimeout(10*time.Second),
4140
wait.ForListeningPort(fabricPort).WithStartupTimeout(10*time.Second),
4241
wait.ForListeningPort(heartbeatPort).WithStartupTimeout(10*time.Second),
43-
),
42+
)),
4443
}
4544

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-
}
45+
moduleOpts = append(moduleOpts, opts...)
5646

57-
container, err := testcontainers.GenericContainer(ctx, genericContainerReq)
47+
container, err := testcontainers.Run(ctx, img, moduleOpts...)
5848
var c *Container
5949
if container != nil {
6050
c = &Container{Container: container}
6151
}
6252

6353
if err != nil {
64-
return c, fmt.Errorf("generic container: %w", err)
54+
return c, fmt.Errorf("run aerospike: %w", err)
6555
}
6656

6757
return c, nil

0 commit comments

Comments
 (0)