@@ -13,15 +13,17 @@ import (
1313 "github.com/testcontainers/testcontainers-go/wait"
1414 "os"
1515 "path/filepath"
16+ "strings"
1617 "sync"
1718 "text/template"
1819 "time"
1920)
2021
2122const (
22- DefaultHTTPPort = "6688"
23- DefaultP2PPort = "6690"
24- TmpImageName = "chainlink-tmp:latest"
23+ DefaultHTTPPort = "6688"
24+ DefaultP2PPort = "6690"
25+ TmpImageName = "chainlink-tmp:latest"
26+ CustomPortSeparator = ":"
2527)
2628
2729var (
@@ -50,7 +52,7 @@ type NodeInput struct {
5052 UserSecretsOverrides string `toml:"user_secrets_overrides"`
5153 HTTPPort int `toml:"port"`
5254 P2PPort int `toml:"p2p_port"`
53- CustomPorts []int `toml:"custom_ports"`
55+ CustomPorts []string `toml:"custom_ports"`
5456}
5557
5658// Output represents Chainlink node output, nodes and databases connection URLs
@@ -153,12 +155,6 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
153155 } else {
154156 containerName = framework .DefaultTCName ("node" )
155157 }
156- customPorts := make ([]string , 0 )
157- for _ , p := range in .Node .CustomPorts {
158- customPorts = append (customPorts , fmt .Sprintf ("%d/tcp" , p ))
159- }
160- exposedPorts := []string {httpPort }
161- exposedPorts = append (exposedPorts , customPorts ... )
162158
163159 portBindings := nat.PortMap {
164160 nat .Port (httpPort ): []nat.PortBinding {
@@ -168,14 +164,35 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
168164 },
169165 },
170166 }
171- for _ , p := range customPorts {
172- portBindings [nat .Port (p )] = []nat.PortBinding {
173- {
174- HostIP : "0.0.0.0" ,
175- HostPort : p ,
176- },
167+ customPorts := make ([]string , 0 )
168+ for _ , p := range in .Node .CustomPorts {
169+ if strings .Contains (p , CustomPortSeparator ) {
170+ pp := strings .Split (p , CustomPortSeparator )
171+ if len (pp ) != 2 {
172+ return nil , errors .New ("custom_ports has ':' but you must provide both ports" )
173+ }
174+ customPorts = append (customPorts , fmt .Sprintf ("%s/tcp" , pp [1 ]))
175+ portBindings [nat .Port (fmt .Sprintf ("%s/tcp" , pp [1 ]))] = []nat.PortBinding {
176+ {
177+ HostIP : "0.0.0.0" ,
178+ HostPort : fmt .Sprintf ("%s/tcp" , pp [0 ]),
179+ },
180+ }
181+ framework .L .Warn ().Str ("PortHost" , pp [0 ]).Str ("PortInternal" , pp [1 ]).Send ()
182+ } else {
183+ customPorts = append (customPorts , fmt .Sprintf ("%s/tcp" , p ))
184+ framework .L .Warn ().Str ("Port" , p ).Send ()
185+ portBindings [nat .Port (fmt .Sprintf ("%s/tcp" , p ))] = []nat.PortBinding {
186+ {
187+ HostIP : "0.0.0.0" ,
188+ HostPort : fmt .Sprintf ("%s/tcp" , p ),
189+ },
190+ }
177191 }
178192 }
193+ exposedPorts := []string {httpPort }
194+ exposedPorts = append (exposedPorts , customPorts ... )
195+ framework .L .Warn ().Any ("ExposedPorts" , exposedPorts ).Send ()
179196
180197 req := tc.ContainerRequest {
181198 AlwaysPullImage : in .Node .PullImage ,
0 commit comments