@@ -190,6 +190,12 @@ func (a *App) printOpenSSHConfig(ctx context.Context, opts configOptions, execut
190190 return fmt .Errorf ("error getting codespace info: %w" , err )
191191 }
192192
193+ type sshResult struct {
194+ codespace * api.Codespace
195+ user string // on success, the remote ssh username; else nil
196+ err error
197+ }
198+
193199 sshUsers := make (chan sshResult )
194200 fetches := 0
195201 var status error
@@ -258,6 +264,24 @@ func (a *App) printOpenSSHConfig(ctx context.Context, opts configOptions, execut
258264 continue
259265 }
260266
267+ // codespaceSSHConfig contains values needed to write an OpenSSH host
268+ // configuration for a single codespace. For example:
269+ //
270+ // Host {{Name}}.{{EscapedRef}
271+ // User {{SSHUser}
272+ // ProxyCommand {{GHExec}} cs ssh -c {{Name}} --stdio
273+ //
274+ // EscapedRef is included in the name to help distinguish between codespaces
275+ // when tab-completing ssh hostnames. '/' characters in EscapedRef are
276+ // flattened to '-' to prevent problems with tab completion or when the
277+ // hostname appears in ControlMaster socket paths.
278+ type codespaceSSHConfig struct {
279+ Name string // the codespace name, passed to `ssh -c`
280+ EscapedRef string // the currently checked-out branch
281+ SSHUser string // the remote ssh username
282+ GHExec string // path used for invoking the current `gh` binary
283+ }
284+
261285 conf := codespaceSSHConfig {
262286 Name : result .codespace .Name ,
263287 EscapedRef : strings .ReplaceAll (result .codespace .GitStatus .Ref , "/" , "-" ),
@@ -272,30 +296,6 @@ func (a *App) printOpenSSHConfig(ctx context.Context, opts configOptions, execut
272296 return status
273297}
274298
275- type sshResult struct {
276- codespace * api.Codespace
277- user string // on success, the remote ssh username; else nil
278- err error
279- }
280-
281- // codespaceSSHConfig contains values needed to write an OpenSSH host
282- // configuration for a single codespace. For example:
283- //
284- // Host {{Name}}.{{EscapedRef}
285- // User {{SSHUser}
286- // ProxyCommand {{GHExec}} cs ssh -c {{Name}} --stdio
287- //
288- // EscapedRef is included in the name to help distinguish between codespaces
289- // when tab-completing ssh hostnames. '/' characters in EscapedRef are
290- // flattened to '-' to prevent problems with tab completion or when the
291- // hostname appears in ControlMaster socket paths.
292- type codespaceSSHConfig struct {
293- Name string // the codespace name, passed to `ssh -c`
294- EscapedRef string // the currently checked-out branch
295- SSHUser string // the remote ssh username
296- GHExec string // path used for invoking the current `gh` binary
297- }
298-
299299func (a * App ) openSSHSession (ctx context.Context , codespace * api.Codespace , liveshareLogger * log.Logger ) (* liveshare.Session , error ) {
300300 if liveshareLogger == nil {
301301 liveshareLogger = noopLogger ()
0 commit comments