aboutsummaryrefslogtreecommitdiff
path: root/src/garage/cli
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-08 20:15:55 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-08 20:15:55 +0200
commit5b38f4cd26a9517172e7f2ce2f4e8b957c7c39c2 (patch)
tree8c9428c0bcc8f2c97a30d1eb30b71c7d67d2fbce /src/garage/cli
parent17e111139308ba995fb782cbd1af555920cbbb81 (diff)
downloadgarage-5b38f4cd26a9517172e7f2ce2f4e8b957c7c39c2.tar.gz
garage-5b38f4cd26a9517172e7f2ce2f4e8b957c7c39c2.zip
Show bucket sizes in garage bucket list
Diffstat (limited to 'src/garage/cli')
-rw-r--r--src/garage/cli/cmd.rs4
-rw-r--r--src/garage/cli/util.rs21
2 files changed, 19 insertions, 6 deletions
diff --git a/src/garage/cli/cmd.rs b/src/garage/cli/cmd.rs
index 3a0bd956..e8e834e8 100644
--- a/src/garage/cli/cmd.rs
+++ b/src/garage/cli/cmd.rs
@@ -166,8 +166,8 @@ pub async fn cmd_admin(
AdminRpc::Ok(msg) => {
println!("{}", msg);
}
- AdminRpc::BucketList(bl) => {
- print_bucket_list(bl);
+ AdminRpc::BucketList { buckets, counters } => {
+ print_bucket_list(buckets, counters);
}
AdminRpc::BucketInfo {
bucket,
diff --git a/src/garage/cli/util.rs b/src/garage/cli/util.rs
index 23c669b9..f859c9bc 100644
--- a/src/garage/cli/util.rs
+++ b/src/garage/cli/util.rs
@@ -9,11 +9,11 @@ use garage_model::bucket_table::*;
use garage_model::key_table::*;
use garage_model::s3::object_table::{BYTES, OBJECTS, UNFINISHED_UPLOADS};
-pub fn print_bucket_list(bl: Vec<Bucket>) {
+pub fn print_bucket_list(buckets: Vec<Bucket>, counters: HashMap<Uuid, HashMap<String, i64>>) {
println!("List of buckets:");
let mut table = vec![];
- for bucket in bl {
+ for bucket in buckets {
let aliases = bucket
.aliases()
.iter()
@@ -30,11 +30,24 @@ pub fn print_bucket_list(bl: Vec<Bucket>) {
[((k, n), _, _)] => format!("{}:{}", k, n),
s => format!("[{} local aliases]", s.len()),
};
+
+ let counters_tb = match counters.get(&bucket.id) {
+ Some(c) => format!(
+ "\t{}\t{}\t{}",
+ bytesize::ByteSize::b(c.get(BYTES).cloned().unwrap_or_default() as u64)
+ .to_string_as(true),
+ c.get(OBJECTS).cloned().unwrap_or_default(),
+ c.get(UNFINISHED_UPLOADS).cloned().unwrap_or_default(),
+ ),
+ None => "".into(),
+ };
+
table.push(format!(
- "\t{}\t{}\t{}",
+ "\t{}\t{}\t{}{}",
aliases.join(","),
local_aliases_n,
- hex::encode(bucket.id)
+ hex::encode(bucket.id),
+ counters_tb
));
}
format_table(table);