aboutsummaryrefslogtreecommitdiff
path: root/src/garage/cli
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-14 13:55:11 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:45:46 +0100
commit5b1117e582db16cc5aa50840a685875cbd5501f4 (patch)
tree06fec47bf56cb08cb51334454dc15f98352c98f2 /src/garage/cli
parent8f6026de5ecd44cbe0fc0bcd47638a1ece860439 (diff)
downloadgarage-5b1117e582db16cc5aa50840a685875cbd5501f4.tar.gz
garage-5b1117e582db16cc5aa50840a685875cbd5501f4.zip
New model for buckets
Diffstat (limited to 'src/garage/cli')
-rw-r--r--src/garage/cli/cmd.rs7
-rw-r--r--src/garage/cli/util.rs53
2 files changed, 44 insertions, 16 deletions
diff --git a/src/garage/cli/cmd.rs b/src/garage/cli/cmd.rs
index a916974e..3cdf4d26 100644
--- a/src/garage/cli/cmd.rs
+++ b/src/garage/cli/cmd.rs
@@ -161,8 +161,11 @@ pub async fn cmd_admin(
}
AdminRpc::BucketList(bl) => {
println!("List of buckets:");
- for bucket in bl {
- println!("{}", bucket);
+ for alias in bl {
+ if let Some(p) = alias.state.get().as_option() {
+ let wflag = if p.website_access { "W" } else { " " };
+ println!("- {} {} {:?}", wflag, alias.name, p.bucket_id);
+ }
}
}
AdminRpc::BucketInfo(bucket) => {
diff --git a/src/garage/cli/util.rs b/src/garage/cli/util.rs
index 647a2449..be34183e 100644
--- a/src/garage/cli/util.rs
+++ b/src/garage/cli/util.rs
@@ -1,3 +1,4 @@
+use garage_util::crdt::*;
use garage_util::data::Uuid;
use garage_util::error::*;
@@ -8,26 +9,50 @@ pub fn print_key_info(key: &Key) {
println!("Key name: {}", key.name.get());
println!("Key ID: {}", key.key_id);
println!("Secret key: {}", key.secret_key);
- if key.deleted.get() {
- println!("Key is deleted.");
- } else {
- println!("Authorized buckets:");
- for (b, _, perm) in key.authorized_buckets.items().iter() {
- println!("- {} R:{} W:{}", b, perm.allow_read, perm.allow_write);
+ match &key.state {
+ Deletable::Present(p) => {
+ println!("\nKey-specific bucket aliases:");
+ for (alias_name, _, alias) in p.local_aliases.items().iter() {
+ if let Some(bucket_id) = alias.as_option() {
+ println!("- {} {:?}", alias_name, bucket_id);
+ }
+ }
+ println!("\nAuthorized buckets:");
+ for (b, perm) in p.authorized_buckets.items().iter() {
+ let rflag = if perm.allow_read { "R" } else { " " };
+ let wflag = if perm.allow_write { "W" } else { " " };
+ println!("- {}{} {:?}", rflag, wflag, b);
+ }
+ }
+ Deletable::Deleted => {
+ println!("\nKey is deleted.");
}
}
}
pub fn print_bucket_info(bucket: &Bucket) {
- println!("Bucket name: {}", bucket.name);
- match bucket.state.get() {
- BucketState::Deleted => println!("Bucket is deleted."),
- BucketState::Present(p) => {
- println!("Authorized keys:");
- for (k, _, perm) in p.authorized_keys.items().iter() {
- println!("- {} R:{} W:{}", k, perm.allow_read, perm.allow_write);
+ println!("Bucket: {}", hex::encode(bucket.id));
+ match &bucket.state {
+ Deletable::Deleted => println!("Bucket is deleted."),
+ Deletable::Present(p) => {
+ println!("\nGlobal aliases:");
+ for (alias, _, active) in p.aliases.items().iter() {
+ if *active {
+ println!("- {}", alias);
+ }
+ }
+ println!("\nKey-specific aliases:");
+ for ((key_id, alias), _, active) in p.local_aliases.items().iter() {
+ if *active {
+ println!("- {} {}", key_id, alias);
+ }
+ }
+ println!("\nAuthorized keys:");
+ for (k, perm) in p.authorized_keys.items().iter() {
+ let rflag = if perm.allow_read { "R" } else { " " };
+ let wflag = if perm.allow_write { "W" } else { " " };
+ println!("- {}{} {}", rflag, wflag, k);
}
- println!("Website access: {}", p.website.get());
}
};
}