From fef8bf6dba19ff1f88f0b66d05d6205a3b180972 Mon Sep 17 00:00:00 2001
From: Mateusz Kaczanowski <kaczanowski.mateusz@gmail.com>
Date: Mon, 15 Jan 2024 05:43:36 +0100
Subject: [PATCH] add exportable flag to hashicorp::upload

---
 src/commands/hashicorp/upload.rs          | 6 ++++++
 src/keyring/providers/hashicorp/client.rs | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/src/commands/hashicorp/upload.rs b/src/commands/hashicorp/upload.rs
index ee4977c3..51be2b4f 100644
--- a/src/commands/hashicorp/upload.rs
+++ b/src/commands/hashicorp/upload.rs
@@ -47,6 +47,10 @@ pub struct UploadCommand {
     /// verify that provided key name is defined in the config
     #[clap(long = "no-check-defined-key")]
     no_check_defined_key: bool,
+
+    /// this allows for all the valid keys in the key ring to be exported. Once set, this cannot be disabled.
+    #[clap(long = "exportable")]
+    exportable: bool,
 }
 
 /// Import Secret Key Request
@@ -184,6 +188,7 @@ impl UploadCommand {
             &self.key_name,
             client::CreateKeyType::Ed25519,
             &base64::encode(wrapped_aes),
+            self.exportable,
         )
         .expect("import key error!");
     }
@@ -297,6 +302,7 @@ mod tests {
             payload: Some(ED25519.into()),
             payload_file: None,
             no_check_defined_key: false,
+            exportable: false,
         };
 
         let config = HashiCorpConfig {
diff --git a/src/keyring/providers/hashicorp/client.rs b/src/keyring/providers/hashicorp/client.rs
index fc2e08e8..8c23f554 100644
--- a/src/keyring/providers/hashicorp/client.rs
+++ b/src/keyring/providers/hashicorp/client.rs
@@ -61,6 +61,7 @@ pub(crate) struct ImportRequest {
     pub r#type: String,
     pub ciphertext: String,
     pub hash_function: String,
+    pub exportable: bool,
 }
 
 #[allow(dead_code)]
@@ -365,11 +366,13 @@ impl TendermintValidatorApp {
         key_name: &str,
         key_type: CreateKeyType,
         ciphertext: &str,
+        exportable: bool,
     ) -> Result<(), Error> {
         let body = ImportRequest {
             r#type: key_type.to_string(),
             ciphertext: ciphertext.into(),
             hash_function: "SHA256".into(),
+            exportable,
         };
 
         let _ = self