aboutsummaryrefslogtreecommitdiff
path: root/src/garage/admin_rpc.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-03-18 19:24:59 +0100
committerAlex Auvolat <alex@adnab.me>2021-03-18 19:24:59 +0100
commit4eb16e886388f35d2bdee52b16922421004cf132 (patch)
tree9c15b75b6e647aad729042e0e91b3cbbde81f15f /src/garage/admin_rpc.rs
parent8e317e2783189723376074845e8b6c55ded79ecb (diff)
downloadgarage-4eb16e886388f35d2bdee52b16922421004cf132.tar.gz
garage-4eb16e886388f35d2bdee52b16922421004cf132.zip
Allow to import keys from previous Garage instancedev-0.2
Diffstat (limited to 'src/garage/admin_rpc.rs')
-rw-r--r--src/garage/admin_rpc.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/garage/admin_rpc.rs b/src/garage/admin_rpc.rs
index 10087f74..df00fcaf 100644
--- a/src/garage/admin_rpc.rs
+++ b/src/garage/admin_rpc.rs
@@ -245,6 +245,17 @@ impl AdminRpcHandler {
key.key_id
)))
}
+ KeyOperation::Import(query) => {
+ let prev_key = self.garage.key_table.get(&EmptyKey, &query.key_id)
+ .await?;
+ if prev_key.is_some() {
+ return Err(Error::Message(format!("Key {} already exists in data store. Even if it is deleted, we can't let you create a new key with the same ID. Sorry.", query.key_id)));
+ }
+ let imported_key = Key::import(&query.key_id, &query.secret_key, &query.name);
+ self.garage.key_table.insert(&imported_key).await?;
+ Ok(AdminRPC::KeyInfo(imported_key))
+
+ }
}
}