Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit55bec81

Browse files
committed
feat: autostart workspaces on ssh
1 parent2e4e0b2 commit55bec81

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

‎cli/configssh.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"path/filepath"
1414
"runtime"
1515
"sort"
16+
"strconv"
1617
"strings"
1718

1819
"github.com/cli/safeexec"
@@ -46,9 +47,10 @@ const (
4647
// sshConfigOptions represents options that can be stored and read
4748
// from the coder config in ~/.ssh/coder.
4849
typesshConfigOptionsstruct {
49-
waitEnumstring
50-
userHostPrefixstring
51-
sshOptions []string
50+
waitEnumstring
51+
userHostPrefixstring
52+
sshOptions []string
53+
disableAutostartbool
5254
}
5355

5456
// addOptions expects options in the form of "option=value" or "option value".
@@ -106,7 +108,7 @@ func (o sshConfigOptions) equal(other sshConfigOptions) bool {
106108
if!slices.Equal(opt1,opt2) {
107109
returnfalse
108110
}
109-
returno.waitEnum==other.waitEnum&&o.userHostPrefix==other.userHostPrefix
111+
returno.waitEnum==other.waitEnum&&o.userHostPrefix==other.userHostPrefix&&o.disableAutostart==other.disableAutostart
110112
}
111113

112114
func (osshConfigOptions)asList() (list []string) {
@@ -116,6 +118,9 @@ func (o sshConfigOptions) asList() (list []string) {
116118
ifo.userHostPrefix!="" {
117119
list=append(list,fmt.Sprintf("ssh-host-prefix: %s",o.userHostPrefix))
118120
}
121+
ifo.disableAutostart {
122+
list=append(list,fmt.Sprintf("disable-autostart: %v",o.disableAutostart))
123+
}
119124
for_,opt:=rangeo.sshOptions {
120125
list=append(list,fmt.Sprintf("ssh-option: %s",opt))
121126
}
@@ -392,6 +397,9 @@ func (r *RootCmd) configSSH() *clibase.Cmd {
392397
ifsshConfigOpts.waitEnum!="auto" {
393398
flags+=" --wait="+sshConfigOpts.waitEnum
394399
}
400+
ifsshConfigOpts.disableAutostart {
401+
flags+=" --disable-autostart=true"
402+
}
395403
defaultOptions=append(defaultOptions,fmt.Sprintf(
396404
"ProxyCommand %s --global-config %s ssh --stdio%s %s",
397405
escapedCoderBinary,escapedGlobalConfig,flags,workspaceHostname,
@@ -566,6 +574,13 @@ func (r *RootCmd) configSSH() *clibase.Cmd {
566574
Default:"auto",
567575
Value:clibase.EnumOf(&sshConfigOpts.waitEnum,"yes","no","auto"),
568576
},
577+
{
578+
Flag:"disable-autostart",
579+
Description:"Disable starting the workspace automatically when connecting via SSH.",
580+
Env:"CODER_CONFIGSSH_DISABLE_AUTOSTART",
581+
Value:clibase.BoolOf(&sshConfigOpts.disableAutostart),
582+
Default:"false",
583+
},
569584
{
570585
Flag:"force-unix-filepaths",
571586
Env:"CODER_CONFIGSSH_UNIX_FILEPATHS",
@@ -602,6 +617,9 @@ func sshConfigWriteSectionHeader(w io.Writer, addNewline bool, o sshConfigOption
602617
ifo.userHostPrefix!="" {
603618
_,_=fmt.Fprintf(&ow,"# :%s=%s\n","ssh-host-prefix",o.userHostPrefix)
604619
}
620+
ifo.disableAutostart {
621+
_,_=fmt.Fprintf(&ow,"# :%s=%v\n","disable-autostart",o.disableAutostart)
622+
}
605623
for_,opt:=rangeo.sshOptions {
606624
_,_=fmt.Fprintf(&ow,"# :%s=%s\n","ssh-option",opt)
607625
}
@@ -634,6 +652,8 @@ func sshConfigParseLastOptions(r io.Reader) (o sshConfigOptions) {
634652
o.userHostPrefix=parts[1]
635653
case"ssh-option":
636654
o.sshOptions=append(o.sshOptions,parts[1])
655+
case"disable-autostart":
656+
o.disableAutostart,_=strconv.ParseBool(parts[1])
637657
default:
638658
// Unknown option, ignore.
639659
}

‎cli/ssh.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ var (
4444

4545
func (r*RootCmd)ssh()*clibase.Cmd {
4646
var (
47-
stdiobool
48-
forwardAgentbool
49-
forwardGPGbool
50-
identityAgentstring
51-
wsPollInterval time.Duration
52-
waitEnumstring
53-
noWaitbool
54-
logDirPathstring
55-
remoteForwardstring
47+
stdiobool
48+
forwardAgentbool
49+
forwardGPGbool
50+
identityAgentstring
51+
wsPollInterval time.Duration
52+
waitEnumstring
53+
noWaitbool
54+
logDirPathstring
55+
remoteForwardstring
56+
disableAutostartbool
5657
)
5758
client:=new(codersdk.Client)
5859
cmd:=&clibase.Cmd{
@@ -459,6 +460,13 @@ func (r *RootCmd) ssh() *clibase.Cmd {
459460
FlagShorthand:"R",
460461
Value:clibase.StringOf(&remoteForward),
461462
},
463+
{
464+
Flag:"disable-autostart",
465+
Description:"Disable starting the workspace automatically when connecting via SSH.",
466+
Env:"CODER_SSH_DISABLE_AUTOSTART",
467+
Value:clibase.BoolOf(&disableAutostart),
468+
Default:"false",
469+
},
462470
}
463471
returncmd
464472
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp