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 } ;
12use std:: collections:: HashMap ;
23use std:: io:: Write ;
34use std:: path:: { Path , PathBuf } ;
@@ -64,10 +65,10 @@ impl Credentials {
6465 /// - If non-SSH credentials are use, `Err` is returned.
6566 /// - If creation of the temporary file fails, `Err` is returned.
6667 ///
67- pub fn write_temporary_ssh_key ( & self ) -> Result < tempfile:: TempPath , PerformError > {
68+ pub fn write_temporary_ssh_key ( & self ) -> anyhow :: Result < tempfile:: TempPath > {
6869 let key = match self {
6970 Credentials :: Ssh { key } => key,
70- _ => return Err ( "SSH key not available" . into ( ) ) ,
71+ _ => return Err ( anyhow ! ( "SSH key not available" ) ) ,
7172 } ;
7273
7374 let dir = if cfg ! ( target_os = "linux" ) {
@@ -78,8 +79,13 @@ impl Credentials {
7879 std:: env:: temp_dir ( )
7980 } ;
8081
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" ) ?;
8389
8490 Ok ( temp_key_file. into_temp_path ( ) )
8591 }
You can’t perform that action at this time.
0 commit comments