@@ -11,6 +11,7 @@ import (
1111 "time"
1212
1313 "github.com/spf13/afero"
14+ "github.com/brevdev/brev-cli/pkg/errors"
1415)
1516
1617// RemoteRunner executes commands on a Spark host over ssh and returns stdout/stderr.
@@ -25,15 +26,15 @@ func NewRemoteRunner(fs afero.Fs) RemoteRunner {
2526// Run executes the provided remote shell command via ssh and returns combined output.
2627func (r RemoteRunner ) Run (ctx context.Context , host Host , remoteCmd string ) (string , error ) {
2728 if host .IdentityFile == "" {
28- return "" , fmt .Errorf ("missing identity file for %s" , host .Alias )
29+ return "" , errors . WrapAndTrace ( fmt .Errorf ("missing identity file for %s" , host .Alias ) )
2930 }
3031
3132 exists , err := afero .Exists (r .fs , host .IdentityFile )
3233 if err != nil {
3334 return "" , err
3435 }
3536 if ! exists {
36- return "" , fmt .Errorf ("identity file not found at %s" , host .IdentityFile )
37+ return "" , errors . WrapAndTrace ( fmt .Errorf ("identity file not found at %s" , host .IdentityFile ) )
3738 }
3839
3940 argv := buildSSHCommand (host , remoteCmd )
@@ -44,7 +45,7 @@ func (r RemoteRunner) Run(ctx context.Context, host Host, remoteCmd string) (str
4445 cmd .Stderr = & buf
4546
4647 if err := cmd .Run (); err != nil {
47- return buf .String (), fmt .Errorf ("ssh to %s failed for command %q: %w\n output:\n %s" , hostLabel (host ), remoteCmd , err , buf .String ())
48+ return buf .String (), errors . WrapAndTrace ( fmt .Errorf ("ssh to %s failed for command %q: %w\n output:\n %s" , hostLabel (host ), remoteCmd , err , buf .String () ))
4849 }
4950 return buf .String (), nil
5051}
0 commit comments