@@ -55,15 +55,15 @@ func Shell(w io.Writer, projectDir string, githubUsername string) error {
55
55
// for github username.
56
56
telemetryShellStartTime := time .Now ()
57
57
58
- sshClient := openssh.Client {
59
- Username : username ,
60
- Addr : "gateway.devbox.sh" ,
58
+ sshCmd := & openssh.Cmd {
59
+ Username : username ,
60
+ DestinationAddr : "gateway.devbox.sh" ,
61
61
}
62
62
// When developing we can use this env variable to point
63
63
// to a different gateway
64
64
var err error
65
65
if envGateway := os .Getenv ("DEVBOX_GATEWAY" ); envGateway != "" {
66
- sshClient . Addr = envGateway
66
+ sshCmd . DestinationAddr = envGateway
67
67
err = openssh .SetupInsecureDebug (envGateway )
68
68
} else {
69
69
err = openssh .SetupDevbox ()
@@ -84,7 +84,7 @@ func Shell(w io.Writer, projectDir string, githubUsername string) error {
84
84
color .New (color .FgGreen ).Fprintln (w , "Detected existing virtual machine" )
85
85
} else {
86
86
var region , vmUser string
87
- vmUser , vmHostname , region , err = getVirtualMachine (sshClient )
87
+ vmUser , vmHostname , region , err = getVirtualMachine (sshCmd )
88
88
if err != nil {
89
89
return err
90
90
}
@@ -191,8 +191,8 @@ func (vm vm) redact() *vm {
191
191
return & vm
192
192
}
193
193
194
- func getVirtualMachine (client openssh.Client ) (vmUser , vmHost , region string , err error ) {
195
- sshOut , err := client . Exec ("auth" )
194
+ func getVirtualMachine (sshCmd * openssh.Cmd ) (vmUser , vmHost , region string , err error ) {
195
+ sshOut , err := sshCmd . ExecRemote ("auth" )
196
196
if err != nil {
197
197
return "" , "" , "" , errors .Wrapf (err , "error requesting VM" )
198
198
}
@@ -280,19 +280,20 @@ func updateSyncStatus(mutagenSessionName, username, hostname, relProjectPathInVM
280
280
status := "disconnected"
281
281
282
282
// Ensure the destination directory exists
283
- destServer := fmt .Sprintf ("%s@%s" , username , hostname )
284
283
destDir := fmt .Sprintf ("/home/%s/.config/devbox/starship/%s" , username , hyphenatePath (filepath .Base (relProjectPathInVM )))
285
- remoteCmd := fmt .Sprintf ("mkdir -p %s" , destDir )
286
- cmd := exec .Command ("ssh" , destServer , remoteCmd )
287
- err := cmd .Run ()
288
- debug .Log ("mkdir starship mutagen_status command: %s with error: %s" , cmd , err )
284
+ mkdirCmd := openssh .Command (username , hostname )
285
+ _ , err := mkdirCmd .ExecRemote (fmt .Sprintf (`mkdir -p "%s"` , destDir ))
286
+ if err != nil {
287
+ debug .Log ("error setting initial starship mutagen status: %v" , err )
288
+ }
289
289
290
290
// Set an initial status
291
291
displayableStatus := "initial sync"
292
- remoteCmd = fmt .Sprintf ("echo %s > %s/mutagen_status.txt" , displayableStatus , destDir )
293
- cmd = exec .Command ("ssh" , destServer , remoteCmd )
294
- err = cmd .Run ()
295
- debug .Log ("scp starship.toml with command: %s and error: %s" , cmd , err )
292
+ statusCmd := openssh .Command (username , hostname )
293
+ _ , err = statusCmd .ExecRemote (fmt .Sprintf (`echo "%s" > "%s/mutagen_status.txt"` , displayableStatus , destDir ))
294
+ if err != nil {
295
+ debug .Log ("error setting initial starship mutagen status: %v" , err )
296
+ }
296
297
time .Sleep (5 * time .Second )
297
298
298
299
debug .Log ("Starting check for file sync status" )
@@ -309,10 +310,11 @@ func updateSyncStatus(mutagenSessionName, username, hostname, relProjectPathInVM
309
310
displayableStatus = "\" watching for changes\" "
310
311
}
311
312
312
- remoteCmd = fmt .Sprintf ("echo %s > %s/mutagen_status.txt" , displayableStatus , destDir )
313
- cmd = exec .Command ("ssh" , destServer , remoteCmd )
314
- err = cmd .Run ()
315
- debug .Log ("scp starship.toml with command: %s and error: %s" , cmd , err )
313
+ statusCmd := openssh .Command (username , hostname )
314
+ _ , err = statusCmd .ExecRemote (fmt .Sprintf (`echo "%s" > "%s/mutagen_status.txt"` , displayableStatus , destDir ))
315
+ if err != nil {
316
+ debug .Log ("error setting initial starship mutagen status: %v" , err )
317
+ }
316
318
time .Sleep (5 * time .Second )
317
319
}
318
320
}
@@ -335,18 +337,18 @@ func getSyncStatus(mutagenSessionName string) (string, error) {
335
337
func copyConfigFileToVM (hostname , username , projectDir , pathInVM string ) error {
336
338
337
339
// Ensure the devbox-project's directory exists in the VM
338
- destServer := fmt .Sprintf ("%s@%s" , username , hostname )
339
- cmd := exec .Command ("ssh" , destServer , "--" , "mkdir" , "-p" , pathInVM )
340
- err := cmd .Run ()
341
- debug .Log ("ssh mkdir command: %s with error: %s" , cmd , err )
340
+ mkdirCmd := openssh .Command (username , hostname )
341
+ _ , err := mkdirCmd .ExecRemote (fmt .Sprintf (`mkdir -p "%s"` , pathInVM ))
342
342
if err != nil {
343
+ debug .Log ("error copying config file to VM: %v" , err )
343
344
return errors .WithStack (err )
344
345
}
345
346
346
347
// Copy the config file to the devbox-project directory in the VM
348
+ destServer := fmt .Sprintf ("%s@%s" , username , hostname )
347
349
configFilePath := filepath .Join (projectDir , "devbox.json" )
348
350
destPath := fmt .Sprintf ("%s:%s" , destServer , pathInVM )
349
- cmd = exec .Command ("scp" , configFilePath , destPath )
351
+ cmd : = exec .Command ("scp" , configFilePath , destPath )
350
352
err = cmd .Run ()
351
353
debug .Log ("scp devbox.json command: %s with error: %s" , cmd , err )
352
354
return errors .WithStack (err )
@@ -358,14 +360,14 @@ func shell(username, hostname, projectDir string, shellStartTime time.Time) erro
358
360
return err
359
361
}
360
362
361
- client := & openssh.Client {
362
- Addr : hostname ,
363
- PathInVM : absoluteProjectPathInVM (username , projectPath ),
364
- ShellStartTime : telemetry .UnixTimestampFromTime (shellStartTime ),
365
- Username : username ,
363
+ cmd := & openssh.Cmd {
364
+ DestinationAddr : hostname ,
365
+ PathInVM : absoluteProjectPathInVM (username , projectPath ),
366
+ ShellStartTime : telemetry .UnixTimestampFromTime (shellStartTime ),
367
+ Username : username ,
366
368
}
367
369
sessionErrors := newSSHSessionErrors ()
368
- return cloudShellErrorHandler (client .Shell (sessionErrors ), sessionErrors )
370
+ return cloudShellErrorHandler (cmd .Shell (sessionErrors ), sessionErrors )
369
371
}
370
372
371
373
// relativeProjectPathInVM refers to the project path relative to the user's
0 commit comments