Skip to content

Commit 42a7512

Browse files
committed
feat(configssh): add any provided header command to the SSH config also
1 parent b5e5b39 commit 42a7512

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

cli/configssh.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,18 @@ func (r *RootCmd) configSSH() *clibase.Cmd {
388388
}
389389

390390
if !skipProxyCommand {
391+
rootFlags := fmt.Sprintf("--global-config %s", escapedGlobalConfig)
392+
if r.headerCommand != "" {
393+
rootFlags += fmt.Sprintf(" --header-command %s", r.headerCommand)
394+
}
395+
391396
flags := ""
392397
if sshConfigOpts.waitEnum != "auto" {
393398
flags += " --wait=" + sshConfigOpts.waitEnum
394399
}
395400
defaultOptions = append(defaultOptions, fmt.Sprintf(
396-
"ProxyCommand %s --global-config %s ssh --stdio%s %s",
397-
escapedCoderBinary, escapedGlobalConfig, flags, workspaceHostname,
401+
"ProxyCommand %s %s ssh --stdio%s %s",
402+
escapedCoderBinary, rootFlags, flags, workspaceHostname,
398403
))
399404
}
400405

cli/configssh_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,20 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
585585
regexMatch: "ProxyCommand /foo/bar/coder",
586586
},
587587
},
588+
{
589+
name: "Header command",
590+
args: []string{
591+
"--header-command", "/foo/bar/coder",
592+
},
593+
wantErr: false,
594+
echoResponse: &echo.Responses{
595+
Parse: echo.ParseComplete,
596+
ProvisionApply: echo.ProvisionApplyWithAgent(""),
597+
},
598+
wantConfig: wantConfig{
599+
regexMatch: "--header-command /foo/bar/coder ssh",
600+
},
601+
},
588602
}
589603
for _, tt := range tests {
590604
tt := tt

0 commit comments

Comments
 (0)