From 756c5c51fe45cc63bf2f3891eedfd6a4b155c04e Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Tue, 2 Apr 2024 15:20:18 +0400 Subject: [PATCH] Introduce TART_EXECUTOR_SSH_PORT (#69) --- README.md | 1 + internal/tart/config.go | 1 + internal/tart/vm.go | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03efca9..412dc3b 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ that required paid sponsorship upon exceeding a free limit. |---------------------------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `TART_EXECUTOR_SSH_USERNAME` | admin | SSH username to use when connecting to the VM | | `TART_EXECUTOR_SSH_PASSWORD` | admin | SSH password to use when connecting to the VM | +| `TART_EXECUTOR_SSH_PORT` | 22 | Connect to the VM at the given SSH port | | `TART_EXECUTOR_HEADLESS` | true | Run the VM in headless mode (`true`) or with GUI (`false`) | | `TART_EXECUTOR_ALWAYS_PULL` | true | Always pull the latest version of the Tart image (`true`) or only when the image doesn't exist locally (`false`) | | `TART_EXECUTOR_INSECURE_PULL` | false | Set to `true` to connect the OCI registry via insecure HTTP protocol | diff --git a/internal/tart/config.go b/internal/tart/config.go index b6655a1..a3b0a87 100644 --- a/internal/tart/config.go +++ b/internal/tart/config.go @@ -33,6 +33,7 @@ const ( type Config struct { SSHUsername string `env:"SSH_USERNAME" envDefault:"admin"` SSHPassword string `env:"SSH_PASSWORD" envDefault:"admin"` + SSHPort uint16 `env:"SSH_PORT" envDefault:"22"` Softnet bool `env:"SOFTNET"` Headless bool `env:"HEADLESS" envDefault:"true"` AlwaysPull bool `env:"ALWAYS_PULL" envDefault:"true"` diff --git a/internal/tart/vm.go b/internal/tart/vm.go index 20e7b97..179a144 100644 --- a/internal/tart/vm.go +++ b/internal/tart/vm.go @@ -194,7 +194,7 @@ func (vm *VM) OpenSSH(ctx context.Context, config Config) (*ssh.Client, error) { if err != nil { return nil, err } - addr := ip + ":22" + addr := fmt.Sprintf("%s:%d", ip, config.SSHPort) sshConfig := &ssh.ClientConfig{ HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {