@@ -29,14 +29,6 @@ type Container struct {
2929
3030// Run creates an instance of the Socat container type
3131func Run (ctx context.Context , img string , opts ... testcontainers.ContainerCustomizer ) (* Container , error ) {
32- req := testcontainers.GenericContainerRequest {
33- ContainerRequest : testcontainers.ContainerRequest {
34- Image : img ,
35- Entrypoint : []string {"/bin/sh" },
36- },
37- Started : true ,
38- }
39-
4032 // Gather all config options (defaults and then apply provided options)
4133 settings := defaultOptions ()
4234 for _ , opt := range opts {
@@ -45,27 +37,33 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
4537 return nil , err
4638 }
4739 }
48- if err := opt .Customize (& req ); err != nil {
49- return nil , err
50- }
5140 }
5241
42+ moduleOpts := []testcontainers.ContainerCustomizer {
43+ testcontainers .WithEntrypoint ("/bin/sh" ),
44+ }
45+
46+ exposedPorts := []string {}
47+
5348 for k := range settings .targets {
54- req . ExposedPorts = append (req . ExposedPorts , fmt .Sprintf ("%d/tcp" , k ))
49+ exposedPorts = append (exposedPorts , fmt .Sprintf ("%d/tcp" , k ))
5550 }
51+ moduleOpts = append (moduleOpts , testcontainers .WithExposedPorts (exposedPorts ... ))
5652
5753 if settings .targetsCmd != "" {
58- req . Cmd = append (req . Cmd , "-c" , settings .targetsCmd )
54+ moduleOpts = append (moduleOpts , testcontainers . WithCmdArgs ( "-c" , settings .targetsCmd ) )
5955 }
6056
61- container , err := testcontainers .GenericContainer (ctx , req )
57+ moduleOpts = append (moduleOpts , opts ... )
58+
59+ container , err := testcontainers .Run (ctx , img , moduleOpts ... )
6260 var c * Container
6361 if container != nil {
6462 c = & Container {Container : container }
6563 }
6664
6765 if err != nil {
68- return c , fmt .Errorf ("generic container : %w" , err )
66+ return c , fmt .Errorf ("run socat : %w" , err )
6967 }
7068
7169 // Only check if the socat binary is available if there are targets to expose.
0 commit comments