1
- use anyhow:: { Error , anyhow , Context as AnyhowContext } ;
1
+ use anyhow:: { Context as AnyhowContext , Error , anyhow } ;
2
2
use base64:: Engine ;
3
3
use clap:: Parser ;
4
4
use glob:: glob;
5
+ use gpgme:: { Context as GpgmeContext , Protocol } ;
6
+ use openpgp:: { Cert , parse:: Parse } ;
7
+ use pgp:: ser:: Serialize ;
8
+ use pgp:: types:: PublicKeyTrait ;
9
+ use pgp:: { Deserializable , Message , SignedPublicKey } ;
10
+ use sequoia_openpgp as openpgp;
5
11
use serde_yaml:: Value ;
6
12
use std:: fs;
7
13
use std:: fs:: File ;
8
- use gpgme:: { Context as GpgmeContext , Protocol } ;
9
14
use std:: io:: { Read , Write } ;
10
15
use std:: path:: Path ;
11
16
use std:: process:: { Command , Stdio } ;
12
- use pgp:: { SignedPublicKey , Message , Deserializable } ;
13
- use pgp:: ser:: Serialize ;
14
- use pgp:: types:: PublicKeyTrait ;
15
- use sequoia_openpgp as openpgp;
16
- use openpgp:: { parse:: Parse , Cert } ;
17
17
#[ derive( Parser , Debug ) ]
18
18
struct Args {
19
19
/// Base64-encoded private GPG key
@@ -35,10 +35,10 @@ pub fn gpg_mock_private_key() -> Result<String, Error> {
35
35
36
36
pub fn read_public_key ( pub_key_file : & str ) -> String {
37
37
let key_string = fs:: read_to_string ( pub_key_file) . unwrap ( ) ;
38
- return key_string
38
+ return key_string;
39
39
}
40
40
41
- pub fn get_pubkey_fingerprint ( armored_pubkey : & str ) -> Result < String , Error > {
41
+ pub fn get_pubkey_fingerprint ( armored_pubkey : & str ) -> Result < String , Error > {
42
42
let cert = Cert :: from_reader ( armored_pubkey. as_bytes ( ) )
43
43
. map_err ( |err| anyhow ! ( "Failed to parse armored public key: {err}" ) ) ?;
44
44
@@ -57,7 +57,10 @@ pub fn import_gpg_key(key_data: &str) -> anyhow::Result<(), anyhow::Error> {
57
57
let key = SignedPublicKey :: from_bytes ( key_data. as_bytes ( ) )
58
58
. map_err ( |e| anyhow ! ( "Failed to parse PGP key: {e}" ) ) ?;
59
59
60
- key. fingerprint ( ) . as_bytes ( ) . iter ( ) . for_each ( |byte| print ! ( "{:02X}" , byte) ) ;
60
+ key. fingerprint ( )
61
+ . as_bytes ( )
62
+ . iter ( )
63
+ . for_each ( |byte| print ! ( "{:02X}" , byte) ) ;
61
64
62
65
Ok ( ( ) )
63
66
}
@@ -94,7 +97,6 @@ pub fn update_sops_config(public_keys: &str) -> anyhow::Result<(), anyhow::Error
94
97
Ok ( ( ) )
95
98
}
96
99
97
-
98
100
pub fn get_key_fingerprint ( encoded_key : & str ) -> anyhow:: Result < String > {
99
101
let decoded_key = base64:: engine:: general_purpose:: STANDARD
100
102
. decode ( encoded_key)
@@ -125,8 +127,7 @@ pub fn get_key_fingerprint(encoded_key: &str) -> anyhow::Result<String> {
125
127
. wait_with_output ( )
126
128
. context ( "Failed to wait for gpg process" ) ?;
127
129
128
- let output_str =
129
- String :: from_utf8 ( output. stdout ) . context ( "Failed to parse gpg output" ) ?;
130
+ let output_str = String :: from_utf8 ( output. stdout ) . context ( "Failed to parse gpg output" ) ?;
130
131
131
132
let fingerprint = output_str
132
133
. lines ( )
@@ -139,7 +140,6 @@ pub fn get_key_fingerprint(encoded_key: &str) -> anyhow::Result<String> {
139
140
Ok ( encoded)
140
141
}
141
142
142
-
143
143
#[ allow( unused) ]
144
144
pub fn setup_workspace ( ) -> anyhow:: Result < ( ) , anyhow:: Error > {
145
145
println ! ( "Setting up workspace..." ) ;
0 commit comments