diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-23 20:25:45 +0000 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-23 20:25:45 +0000 |
commit | 51fb3799a153a0db990fc74a37563ec612e20fc2 (patch) | |
tree | 65d8c192ab45b878ffc7af1e60f7b0106782a9ae /src/main.rs | |
parent | 4ef84a0558c0bf6641094e762ede0c962781204d (diff) | |
download | garage-51fb3799a153a0db990fc74a37563ec612e20fc2.tar.gz garage-51fb3799a153a0db990fc74a37563ec612e20fc2.zip |
Key management admin commands
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index cf3a4130..2c25aadb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -172,7 +172,7 @@ pub struct DeleteBucketOpt { pub struct PermBucketOpt { /// Access key ID #[structopt(long = "key")] - pub key: String, + pub key_id: String, /// Allow/deny read operations #[structopt(long = "read")] @@ -192,9 +192,17 @@ pub enum KeyOperation { #[structopt(name = "list")] List, + /// Get key info + #[structopt(name = "info")] + Info(KeyOpt), + /// Create new key #[structopt(name = "new")] - New, + New(KeyNewOpt), + + /// Rename key + #[structopt(name = "rename")] + Rename(KeyRenameOpt), /// Delete key #[structopt(name = "delete")] @@ -202,9 +210,35 @@ pub enum KeyOperation { } #[derive(Serialize, Deserialize, StructOpt, Debug)] +pub struct KeyOpt { + /// ID of the key + key_id: String, +} + +#[derive(Serialize, Deserialize, StructOpt, Debug)] +pub struct KeyNewOpt { + /// Name of the key + #[structopt(long = "name", default_value = "Unnamed key")] + name: String, +} + +#[derive(Serialize, Deserialize, StructOpt, Debug)] +pub struct KeyRenameOpt { + /// ID of the key + key_id: String, + + /// New name of the key + new_name: String, +} + +#[derive(Serialize, Deserialize, StructOpt, Debug)] pub struct KeyDeleteOpt { - /// Name of the bucket to delete - bucket: String, + /// ID of the key + key_id: String, + + /// Confirm deletion + #[structopt(long = "yes")] + yes: bool, } #[derive(Serialize, Deserialize, StructOpt, Debug, Clone)] @@ -489,6 +523,15 @@ async fn cmd_admin( AdminRPC::BucketInfo(bucket) => { println!("{:?}", bucket); } + AdminRPC::KeyList(kl) => { + println!("List of keys:"); + for key in kl { + println!("{}\t{}", key.0, key.1); + } + } + AdminRPC::KeyInfo(key) => { + println!("{:?}", key); + } r => { error!("Unexpected response: {:?}", r); } |