File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change
1
+ use anyhow:: { anyhow, Context } ;
1
2
use std:: collections:: HashMap ;
2
3
use std:: io:: Write ;
3
4
use std:: path:: { Path , PathBuf } ;
@@ -64,10 +65,10 @@ impl Credentials {
64
65
/// - If non-SSH credentials are use, `Err` is returned.
65
66
/// - If creation of the temporary file fails, `Err` is returned.
66
67
///
67
- pub fn write_temporary_ssh_key ( & self ) -> Result < tempfile:: TempPath , PerformError > {
68
+ pub fn write_temporary_ssh_key ( & self ) -> anyhow :: Result < tempfile:: TempPath > {
68
69
let key = match self {
69
70
Credentials :: Ssh { key } => key,
70
- _ => return Err ( "SSH key not available" . into ( ) ) ,
71
+ _ => return Err ( anyhow ! ( "SSH key not available" ) ) ,
71
72
} ;
72
73
73
74
let dir = if cfg ! ( target_os = "linux" ) {
@@ -78,8 +79,13 @@ impl Credentials {
78
79
std:: env:: temp_dir ( )
79
80
} ;
80
81
81
- let mut temp_key_file = tempfile:: Builder :: new ( ) . tempfile_in ( dir) ?;
82
- temp_key_file. write_all ( key. as_bytes ( ) ) ?;
82
+ let mut temp_key_file = tempfile:: Builder :: new ( )
83
+ . tempfile_in ( dir)
84
+ . context ( "Failed to create temporary file" ) ?;
85
+
86
+ temp_key_file
87
+ . write_all ( key. as_bytes ( ) )
88
+ . context ( "Failed to write SSH key to temporary file" ) ?;
83
89
84
90
Ok ( temp_key_file. into_temp_path ( ) )
85
91
}
You can’t perform that action at this time.
0 commit comments