feat: add socat container by mdelapenya · Pull Request #3071 · testcontainers/testcontainers-go
- chore: create socat module from modulegen
- chore: implement socat
- chore: bump tc-go
- chore: mod tidy
- chore: fix examples
What does this PR do?
It adds a SOCAT container, a utility container that provides TCP port forwarding and network tunneling between services, enabling transparent communication between containers and networks.
This is particularly useful in testing scenarios where you need to simulate network connections or provide transparent access to services running in different containers.
Why is it important?
It can be used alongside other modules as a helper for network communication
Related issues
- Relates Add SocatContainer testcontainers-node#964
- Relates feat: Add SocatContainer testcontainers-python#795
Other concerns
Other languages are implementing the socat container as part of the core, and we are discussing about it here too. The socat module in this PR just uses the stdlib plus the github.com/docker/go-connections/nat pacakge, so all the pulled packages would already be there when using tc-go.
I understand the benefits for having it in the core library, although with the current project layout it would be more difficult to add it directly in the core, without a package to enclose the functionality: we wouldn't use the same APIs for running it as in the modules, with the socat.Run function. If in the core, we should:
- Create a socat package, which is basically the same as having it in the module
- Add it to the core but exposed as testcontainers.RunSocat which would lose a bit of the semantics provided by the package namespace plus the Run function (as in the rest of the modules)