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 } ;
@@ -61,10 +62,10 @@ impl Credentials {
6162 /// - If non-SSH credentials are use, `Err` is returned.
6263 /// - If creation of the temporary file fails, `Err` is returned.
6364 ///
64- pub fn write_temporary_ssh_key ( & self ) -> Result < tempfile:: TempPath , PerformError > {
65+ pub fn write_temporary_ssh_key ( & self ) -> anyhow :: Result < tempfile:: TempPath > {
6566 let key = match self {
6667 Credentials :: Ssh { key } => key,
67- _ => return Err ( "SSH key not available" . into ( ) ) ,
68+ _ => return Err ( anyhow ! ( "SSH key not available" ) ) ,
6869 } ;
6970
7071 let dir = if cfg ! ( target_os = "linux" ) {
@@ -75,8 +76,13 @@ impl Credentials {
7576 std:: env:: temp_dir ( )
7677 } ;
7778
78- let mut temp_key_file = tempfile:: Builder :: new ( ) . tempfile_in ( dir) ?;
79- temp_key_file. write_all ( key. as_bytes ( ) ) ?;
79+ let mut temp_key_file = tempfile:: Builder :: new ( )
80+ . tempfile_in ( dir)
81+ . context ( "Failed to create temporary file" ) ?;
82+
83+ temp_key_file
84+ . write_all ( key. as_bytes ( ) )
85+ . context ( "Failed to write SSH key to temporary file" ) ?;
8086
8187 Ok ( temp_key_file. into_temp_path ( ) )
8288 }
You can’t perform that action at this time.
0 commit comments