|
1 | 1 | package docker |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
| 4 | + "context" |
5 | 5 | "strings" |
6 | 6 |
|
7 | | - "github.com/google/uuid" |
8 | 7 | "github.com/rs/zerolog" |
9 | 8 | tc "github.com/testcontainers/testcontainers-go" |
| 9 | + tc_network "github.com/testcontainers/testcontainers-go/network" |
10 | 10 |
|
11 | | - "github.com/smartcontractkit/chainlink-testing-framework/lib/mirror" |
12 | 11 | "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" |
13 | 12 | ) |
14 | 13 |
|
15 | 14 | const RetryAttempts = 3 |
16 | | -const defaultRyukImage = "testcontainers/ryuk:0.5.1" |
17 | 15 |
|
18 | 16 | func CreateNetwork(l zerolog.Logger) (*tc.DockerNetwork, error) { |
19 | | - uuidObj, _ := uuid.NewRandom() |
20 | | - var networkName = fmt.Sprintf("network-%s", uuidObj.String()) |
21 | | - ryukImage := mirror.AddMirrorToImageIfSet(defaultRyukImage) |
22 | | - // currently there's no way to use custom Ryuk image with testcontainers-go v0.28.0 :/ |
23 | | - // but we can go around it, by setting TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX env var to |
24 | | - // our custom registry and then using the default Ryuk image |
25 | | - //nolint:staticcheck |
26 | | - reaperCO := tc.WithImageName(ryukImage) |
27 | | - f := false |
28 | | - //nolint:staticcheck |
29 | | - network, err := tc.GenericNetwork(testcontext.Get(nil), tc.GenericNetworkRequest{ |
30 | | - //nolint:staticcheck |
31 | | - NetworkRequest: tc.NetworkRequest{ |
32 | | - Name: networkName, |
33 | | - CheckDuplicate: true, |
34 | | - EnableIPv6: &f, // disabling due to https://github.com/moby/moby/issues/42442 |
35 | | - ReaperOptions: []tc.ContainerOption{ |
36 | | - reaperCO, |
37 | | - }, |
38 | | - }, |
39 | | - }) |
| 17 | + network, err := tc_network.New(context.Background()) |
40 | 18 | if err != nil { |
41 | 19 | return nil, err |
42 | 20 | } |
43 | | - dockerNetwork, ok := network.(*tc.DockerNetwork) |
44 | | - if !ok { |
45 | | - return nil, fmt.Errorf("failed to cast network to *dockertest.Network") |
46 | | - } |
47 | | - l.Trace().Any("network", dockerNetwork).Msgf("created network") |
48 | | - return dockerNetwork, nil |
| 21 | + l.Trace().Str("Name", network.Name).Msg("Created network") |
| 22 | + return network, nil |
49 | 23 | } |
50 | 24 |
|
51 | 25 | type StartContainerRetrier func(l zerolog.Logger, startErr error, req tc.GenericContainerRequest) (tc.Container, error) |
|
0 commit comments