Skip to content

[draft] feat(portforward): Add SSHD module + Ability to port forward#2467

Closed
JulienBreux wants to merge 2 commits intotestcontainers:mainfrom
JulienBreux:feat/portforward
Closed

[draft] feat(portforward): Add SSHD module + Ability to port forward#2467
JulienBreux wants to merge 2 commits intotestcontainers:mainfrom
JulienBreux:feat/portforward

Conversation

@JulienBreux
Copy link
Contributor

@JulienBreux JulienBreux commented Apr 4, 2024

What does this PR do?

Rel: #2212

Why is it important?

To call the host from a container inside a testcontainers container.
Related to Microcks stuff.
(because a Microcks async minion had to call a host development webserver for example)

Related issues

How to test this PR

Use .WithAccessToHost(true)

Signed-off-by: Julien Breux <julienbreux@google.com>
@netlify
Copy link

netlify bot commented Apr 4, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit bf93724
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/660ec3351d0b7d0008413c83
😎 Deploy Preview https://deploy-preview-2467--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

}

// WithRootPassword sets the options
func WithOptions(opts []string) Option {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func WithOptions(opts []string) Option {
func WithCommandOptions(commandOption []string) Option {

// WithRootPassword sets the options
func WithOptions(opts []string) Option {
return func(o *options) {
o.Options = opts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
o.Options = opts
o.CommandOptions = commandOptions

req := testcontainers.ContainerRequest{
Image: defaultImage,
ExposedPorts: []string{defaultPort},
// WaitingFor: wait.ForLog("* Ready to accept connections"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️

}

applyRootPassword(settings.RootPassword)(&genericContainerReq)
applyCommandOptions(settings.Options)(&genericContainerReq)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
applyCommandOptions(settings.Options)(&genericContainerReq)
applyCommandOptions(settings.CommandOptions)(&genericContainerReq)

_, err := testcontainersshd.RunContainer(ctx, opts...)
require.NoError(t, err)

// @TODO: Test the forwarding container <> host
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:trollface:

@JulienBreux
Copy link
Contributor Author

In progress log:
The first idea is to have a SSHD module in my design.
After a full compatible SSHD module, the second idea is to have a PortForwarding option into the main Container perspective to run this SSHD port forwarding system.

@mdelapenya
Copy link
Member

Hi @JulienBreux our idea is to have the sshd container as part of the internals of the library, so the users just set, e.g., a field in the request struct with the list of ports needed by the container, and the library automatically spins up the sshd container under the hood, forwarding those ports to the container through the sshd server container.

req := testcontainers.GenericContainerRequest{
		ContainerRequest: testcontainers.ContainerRequest{
			Image:           "alpine:3.17",
			HostAccessPorts: []int{3000, 8080},
		}
}

I'm currently working on that approach.

@JulienBreux
Copy link
Contributor Author

I'm currently working on that approach.

Hi, don't hesitate, if I can help.
My first idea was to create a module SSHD and then using it in a PortForwarding brick.
I'm waiting for you, no pb :)

@JulienBreux
Copy link
Contributor Author

Closed by #2471
Removing contribution ✅

@JulienBreux JulienBreux deleted the feat/portforward branch April 11, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants