@@ -45,8 +45,10 @@ const (
45
45
// sshConfigOptions represents options that can be stored and read
46
46
// from the coder config in ~/.ssh/coder.
47
47
type sshConfigOptions struct {
48
- waitEnum string
48
+ waitEnum string
49
+ // Deprecated: moving away from prefix to hostnameSuffix
49
50
userHostPrefix string
51
+ hostnameSuffix string
50
52
sshOptions []string
51
53
disableAutostart bool
52
54
header []string
@@ -97,7 +99,11 @@ func (o sshConfigOptions) equal(other sshConfigOptions) bool {
97
99
if ! slicesSortedEqual (o .header , other .header ) {
98
100
return false
99
101
}
100
- return o .waitEnum == other .waitEnum && o .userHostPrefix == other .userHostPrefix && o .disableAutostart == other .disableAutostart && o .headerCommand == other .headerCommand
102
+ return o .waitEnum == other .waitEnum &&
103
+ o .userHostPrefix == other .userHostPrefix &&
104
+ o .disableAutostart == other .disableAutostart &&
105
+ o .headerCommand == other .headerCommand &&
106
+ o .hostnameSuffix == other .hostnameSuffix
101
107
}
102
108
103
109
// slicesSortedEqual compares two slices without side-effects or regard to order.
@@ -119,6 +125,9 @@ func (o sshConfigOptions) asList() (list []string) {
119
125
if o .userHostPrefix != "" {
120
126
list = append (list , fmt .Sprintf ("ssh-host-prefix: %s" , o .userHostPrefix ))
121
127
}
128
+ if o .hostnameSuffix != "" {
129
+ list = append (list , fmt .Sprintf ("hostname-suffix: %s" , o .hostnameSuffix ))
130
+ }
122
131
if o .disableAutostart {
123
132
list = append (list , fmt .Sprintf ("disable-autostart: %v" , o .disableAutostart ))
124
133
}
@@ -314,6 +323,10 @@ func (r *RootCmd) configSSH() *serpent.Command {
314
323
// Override with user flag.
315
324
coderdConfig .HostnamePrefix = sshConfigOpts .userHostPrefix
316
325
}
326
+ if sshConfigOpts .hostnameSuffix != "" {
327
+ // Override with user flag.
328
+ coderdConfig .HostnameSuffix = sshConfigOpts .hostnameSuffix
329
+ }
317
330
318
331
// Write agent configuration.
319
332
defaultOptions := []string {
@@ -518,6 +531,12 @@ func (r *RootCmd) configSSH() *serpent.Command {
518
531
Description : "Override the default host prefix." ,
519
532
Value : serpent .StringOf (& sshConfigOpts .userHostPrefix ),
520
533
},
534
+ {
535
+ Flag : "hostname-suffix" ,
536
+ Env : "CODER_CONFIGSSH_HOSTNAME_SUFFIX" ,
537
+ Description : "Override the default hostname suffix." ,
538
+ Value : serpent .StringOf (& sshConfigOpts .hostnameSuffix ),
539
+ },
521
540
{
522
541
Flag : "wait" ,
523
542
Env : "CODER_CONFIGSSH_WAIT" , // Not to be mixed with CODER_SSH_WAIT.
@@ -568,6 +587,9 @@ func sshConfigWriteSectionHeader(w io.Writer, addNewline bool, o sshConfigOption
568
587
if o .userHostPrefix != "" {
569
588
_ , _ = fmt .Fprintf (& ow , "# :%s=%s\n " , "ssh-host-prefix" , o .userHostPrefix )
570
589
}
590
+ if o .hostnameSuffix != "" {
591
+ _ , _ = fmt .Fprintf (& ow , "# :%s=%s\n " , "hostname-suffix" , o .hostnameSuffix )
592
+ }
571
593
if o .disableAutostart {
572
594
_ , _ = fmt .Fprintf (& ow , "# :%s=%v\n " , "disable-autostart" , o .disableAutostart )
573
595
}
@@ -607,6 +629,8 @@ func sshConfigParseLastOptions(r io.Reader) (o sshConfigOptions) {
607
629
o .waitEnum = parts [1 ]
608
630
case "ssh-host-prefix" :
609
631
o .userHostPrefix = parts [1 ]
632
+ case "hostname-suffix" :
633
+ o .hostnameSuffix = parts [1 ]
610
634
case "ssh-option" :
611
635
o .sshOptions = append (o .sshOptions , parts [1 ])
612
636
case "disable-autostart" :
0 commit comments