aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/Cargo.toml8
-rw-r--r--src/garage/Cargo.toml14
-rw-r--r--src/garage/admin_rpc.rs11
-rw-r--r--src/garage/cli.rs17
-rw-r--r--src/model/Cargo.toml8
-rw-r--r--src/model/key_table.rs9
-rw-r--r--src/rpc/Cargo.toml4
-rw-r--r--src/table/Cargo.toml6
-rw-r--r--src/util/Cargo.toml2
-rw-r--r--src/web/Cargo.toml10
10 files changed, 63 insertions, 26 deletions
diff --git a/src/api/Cargo.toml b/src/api/Cargo.toml
index bce9946e..68105652 100644
--- a/src/api/Cargo.toml
+++ b/src/api/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_api"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "GPL-3.0"
@@ -13,9 +13,9 @@ path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_util = { version = "0.1.1", path = "../util" }
-garage_table = { version = "0.1.1", path = "../table" }
-garage_model = { version = "0.1.1", path = "../model" }
+garage_util = { version = "0.2.0", path = "../util" }
+garage_table = { version = "0.2.0", path = "../table" }
+garage_model = { version = "0.2.0", path = "../model" }
err-derive = "0.3"
bytes = "1.0"
diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml
index c1817bf2..a5420f8e 100644
--- a/src/garage/Cargo.toml
+++ b/src/garage/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "GPL-3.0"
@@ -14,12 +14,12 @@ path = "main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_util = { version = "0.1.1", path = "../util" }
-garage_rpc = { version = "0.1.1", path = "../rpc" }
-garage_table = { version = "0.1.1", path = "../table" }
-garage_model = { version = "0.1.1", path = "../model" }
-garage_api = { version = "0.1.1", path = "../api" }
-garage_web = { version = "0.1.1", path = "../web" }
+garage_util = { version = "0.2.0", path = "../util" }
+garage_rpc = { version = "0.2.0", path = "../rpc" }
+garage_table = { version = "0.2.0", path = "../table" }
+garage_model = { version = "0.2.0", path = "../model" }
+garage_api = { version = "0.2.0", path = "../api" }
+garage_web = { version = "0.2.0", path = "../web" }
bytes = "1.0"
rand = "0.8"
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))
+
+ }
}
}
diff --git a/src/garage/cli.rs b/src/garage/cli.rs
index e74f59a2..21bafebd 100644
--- a/src/garage/cli.rs
+++ b/src/garage/cli.rs
@@ -194,6 +194,10 @@ pub enum KeyOperation {
/// Delete key
#[structopt(name = "delete")]
Delete(KeyDeleteOpt),
+
+ /// Import key
+ #[structopt(name = "import")]
+ Import(KeyImportOpt),
}
#[derive(Serialize, Deserialize, StructOpt, Debug)]
@@ -228,6 +232,19 @@ pub struct KeyDeleteOpt {
pub yes: bool,
}
+#[derive(Serialize, Deserialize, StructOpt, Debug)]
+pub struct KeyImportOpt {
+ /// Access key ID
+ pub key_id: String,
+
+ /// Secret access key
+ pub secret_key: String,
+
+ /// Key name
+ #[structopt(short = "n", default_value = "Imported key")]
+ pub name: String,
+}
+
#[derive(Serialize, Deserialize, StructOpt, Debug, Clone)]
pub struct RepairOpt {
/// Launch repair operation on all nodes
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 98656ea9..4025f8d0 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_model"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "GPL-3.0"
@@ -13,9 +13,9 @@ path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_util = { version = "0.1.1", path = "../util" }
-garage_rpc = { version = "0.1.1", path = "../rpc" }
-garage_table = { version = "0.1.1", path = "../table" }
+garage_util = { version = "0.2.0", path = "../util" }
+garage_rpc = { version = "0.2.0", path = "../rpc" }
+garage_table = { version = "0.2.0", path = "../table" }
rand = "0.8"
hex = "0.4"
diff --git a/src/model/key_table.rs b/src/model/key_table.rs
index 02dcf68c..fcca3835 100644
--- a/src/model/key_table.rs
+++ b/src/model/key_table.rs
@@ -34,6 +34,15 @@ impl Key {
authorized_buckets: crdt::LWWMap::new(),
}
}
+ pub fn import(key_id: &str, secret_key: &str, name: &str) -> Self {
+ Self {
+ key_id: key_id.to_string(),
+ secret_key: secret_key.to_string(),
+ name: crdt::LWW::new(name.to_string()),
+ deleted: crdt::Bool::new(false),
+ authorized_buckets: crdt::LWWMap::new(),
+ }
+ }
pub fn delete(key_id: String) -> Self {
Self {
key_id,
diff --git a/src/rpc/Cargo.toml b/src/rpc/Cargo.toml
index fbe826a8..4ae53fc8 100644
--- a/src/rpc/Cargo.toml
+++ b/src/rpc/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_rpc"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "GPL-3.0"
@@ -13,7 +13,7 @@ path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_util = { version = "0.1.1", path = "../util" }
+garage_util = { version = "0.2.0", path = "../util" }
bytes = "1.0"
hex = "0.4"
diff --git a/src/table/Cargo.toml b/src/table/Cargo.toml
index f9d98dec..371b73c8 100644
--- a/src/table/Cargo.toml
+++ b/src/table/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_table"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "GPL-3.0"
@@ -13,8 +13,8 @@ path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_util = { version = "0.1.1", path = "../util" }
-garage_rpc = { version = "0.1.1", path = "../rpc" }
+garage_util = { version = "0.2.0", path = "../util" }
+garage_rpc = { version = "0.2.0", path = "../rpc" }
bytes = "1.0"
rand = "0.8"
diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml
index 4698a04f..e72c7ee5 100644
--- a/src/util/Cargo.toml
+++ b/src/util/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_util"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "GPL-3.0"
diff --git a/src/web/Cargo.toml b/src/web/Cargo.toml
index 9aabfe81..a91e3d94 100644
--- a/src/web/Cargo.toml
+++ b/src/web/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_web"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>", "Quentin Dufour <quentin@dufour.io>"]
edition = "2018"
license = "GPL-3.0"
@@ -13,10 +13,10 @@ path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_util = { version = "0.1.1", path = "../util" }
-garage_table = { version = "0.1.1", path = "../table" }
-garage_model = { version = "0.1.1", path = "../model" }
-garage_api = { version = "0.1.1", path = "../api" }
+garage_util = { version = "0.2.0", path = "../util" }
+garage_table = { version = "0.2.0", path = "../table" }
+garage_model = { version = "0.2.0", path = "../model" }
+garage_api = { version = "0.2.0", path = "../api" }
err-derive = "0.3"
log = "0.4"