From e4f955d672af99d1bf25e6a0bb038d116f8bca0c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 16 May 2023 18:34:46 +0200 Subject: fix base64 uses --- src/k2v-client/bin/k2v-cli.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/k2v-client/bin') diff --git a/src/k2v-client/bin/k2v-cli.rs b/src/k2v-client/bin/k2v-cli.rs index cdd63cce..c8418e0d 100644 --- a/src/k2v-client/bin/k2v-cli.rs +++ b/src/k2v-client/bin/k2v-cli.rs @@ -2,6 +2,8 @@ use std::collections::BTreeMap; use std::process::exit; use std::time::Duration; +use base64::prelude::*; + use k2v_client::*; use garage_util::formater::format_table; @@ -155,7 +157,7 @@ impl Value { if let Some(ref text) = self.text { Ok(text.as_bytes().to_vec()) } else if let Some(ref b64) = self.b64 { - base64::decode(b64).map_err(|_| Error::Message("invalid base64 input".into())) + BASE64_STANDARD.decode(b64).map_err(|_| Error::Message("invalid base64 input".into())) } else if let Some(ref path) = self.file { use tokio::io::AsyncReadExt; if path == "-" { @@ -230,7 +232,7 @@ impl ReadOutputKind { for val in val.value { match val { K2vValue::Value(v) => { - println!("{}", base64::encode(&v)) + println!("{}", BASE64_STANDARD.encode(&v)) } K2vValue::Tombstone => { println!(); @@ -249,7 +251,7 @@ impl ReadOutputKind { if let Ok(string) = std::str::from_utf8(&v) { println!(" utf-8: {}", string); } else { - println!(" base64: {}", base64::encode(&v)); + println!(" base64: {}", BASE64_STANDARD.encode(&v)); } } K2vValue::Tombstone => { @@ -284,7 +286,7 @@ impl BatchOutputKind { if let Ok(string) = std::str::from_utf8(&v) { println!(" value(utf-8): {}", string); } else { - println!(" value(base64): {}", base64::encode(&v)); + println!(" value(base64): {}", BASE64_STANDARD.encode(&v)); } } K2vValue::Tombstone => { -- cgit v1.2.3 From bb03805b582562ddec1ac5e8fdc3b31bad070731 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 16 May 2023 18:37:49 +0200 Subject: k2v-cli: fix sort_key being partition_key and specify which key --- src/k2v-client/bin/k2v-cli.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/k2v-client/bin') diff --git a/src/k2v-client/bin/k2v-cli.rs b/src/k2v-client/bin/k2v-cli.rs index c8418e0d..5dad6106 100644 --- a/src/k2v-client/bin/k2v-cli.rs +++ b/src/k2v-client/bin/k2v-cli.rs @@ -277,7 +277,7 @@ struct BatchOutputKind { impl BatchOutputKind { fn display_human_output(&self, values: BTreeMap) -> ! { for (key, values) in values { - println!("key: {}", key); + println!("sort_key: {}", key); let causality: String = values.causality.into(); println!("causality: {}", causality); for value in values.value { @@ -522,7 +522,7 @@ async fn main() -> Result<(), Error> { value .as_object_mut() .unwrap() - .insert("sort_key".to_owned(), k.into()); + .insert("partition_key".to_owned(), k.into()); value }) .collect::>(); @@ -539,7 +539,7 @@ async fn main() -> Result<(), Error> { } let mut to_print = Vec::new(); - to_print.push(format!("key:\tentries\tconflicts\tvalues\tbytes")); + to_print.push(format!("partition_key\tentries\tconflicts\tvalues\tbytes")); for (k, v) in res.items { to_print.push(format!( "{}\t{}\t{}\t{}\t{}", -- cgit v1.2.3 From 16f2a32bb78cdc0d9cee9806c04065af845d0dff Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 16 May 2023 18:40:27 +0200 Subject: cargo fmt --- src/k2v-client/bin/k2v-cli.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/k2v-client/bin') diff --git a/src/k2v-client/bin/k2v-cli.rs b/src/k2v-client/bin/k2v-cli.rs index 5dad6106..e771fe26 100644 --- a/src/k2v-client/bin/k2v-cli.rs +++ b/src/k2v-client/bin/k2v-cli.rs @@ -157,7 +157,9 @@ impl Value { if let Some(ref text) = self.text { Ok(text.as_bytes().to_vec()) } else if let Some(ref b64) = self.b64 { - BASE64_STANDARD.decode(b64).map_err(|_| Error::Message("invalid base64 input".into())) + BASE64_STANDARD + .decode(b64) + .map_err(|_| Error::Message("invalid base64 input".into())) } else if let Some(ref path) = self.file { use tokio::io::AsyncReadExt; if path == "-" { -- cgit v1.2.3