1- use anyhow:: { Error , anyhow , Context as AnyhowContext } ;
1+ use anyhow:: { Context as AnyhowContext , Error , anyhow } ;
22use base64:: Engine ;
33use clap:: Parser ;
44use 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;
511use serde_yaml:: Value ;
612use std:: fs;
713use std:: fs:: File ;
8- use gpgme:: { Context as GpgmeContext , Protocol } ;
914use std:: io:: { Read , Write } ;
1015use std:: path:: Path ;
1116use 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 } ;
1717#[ derive( Parser , Debug ) ]
1818struct Args {
1919 /// Base64-encoded private GPG key
@@ -35,10 +35,10 @@ pub fn gpg_mock_private_key() -> Result<String, Error> {
3535
3636pub fn read_public_key ( pub_key_file : & str ) -> String {
3737 let key_string = fs:: read_to_string ( pub_key_file) . unwrap ( ) ;
38- return key_string
38+ return key_string;
3939}
4040
41- pub fn get_pubkey_fingerprint ( armored_pubkey : & str ) -> Result < String , Error > {
41+ pub fn get_pubkey_fingerprint ( armored_pubkey : & str ) -> Result < String , Error > {
4242 let cert = Cert :: from_reader ( armored_pubkey. as_bytes ( ) )
4343 . map_err ( |err| anyhow ! ( "Failed to parse armored public key: {err}" ) ) ?;
4444
@@ -57,7 +57,10 @@ pub fn import_gpg_key(key_data: &str) -> anyhow::Result<(), anyhow::Error> {
5757 let key = SignedPublicKey :: from_bytes ( key_data. as_bytes ( ) )
5858 . map_err ( |e| anyhow ! ( "Failed to parse PGP key: {e}" ) ) ?;
5959
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) ) ;
6164
6265 Ok ( ( ) )
6366}
@@ -94,7 +97,6 @@ pub fn update_sops_config(public_keys: &str) -> anyhow::Result<(), anyhow::Error
9497 Ok ( ( ) )
9598}
9699
97-
98100pub fn get_key_fingerprint ( encoded_key : & str ) -> anyhow:: Result < String > {
99101 let decoded_key = base64:: engine:: general_purpose:: STANDARD
100102 . decode ( encoded_key)
@@ -125,8 +127,7 @@ pub fn get_key_fingerprint(encoded_key: &str) -> anyhow::Result<String> {
125127 . wait_with_output ( )
126128 . context ( "Failed to wait for gpg process" ) ?;
127129
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" ) ?;
130131
131132 let fingerprint = output_str
132133 . lines ( )
@@ -139,7 +140,6 @@ pub fn get_key_fingerprint(encoded_key: &str) -> anyhow::Result<String> {
139140 Ok ( encoded)
140141}
141142
142-
143143#[ allow( unused) ]
144144pub fn setup_workspace ( ) -> anyhow:: Result < ( ) , anyhow:: Error > {
145145 println ! ( "Setting up workspace..." ) ;
0 commit comments