aboutsummaryrefslogtreecommitdiff
path: root/src/model/key_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-16 13:17:09 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:46:13 +0100
commit4d30e62db456097563c574b9dfd22b138d700087 (patch)
tree00c6790eb7dad952c8e4796731a4ff6e7c3613b6 /src/model/key_table.rs
parent0bbb6673e7ce703e470a3c2aad620ee5f009bc84 (diff)
downloadgarage-4d30e62db456097563c574b9dfd22b138d700087.tar.gz
garage-4d30e62db456097563c574b9dfd22b138d700087.zip
New buckets for 0.6.0: migration code and build files
Diffstat (limited to 'src/model/key_table.rs')
-rw-r--r--src/model/key_table.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/model/key_table.rs b/src/model/key_table.rs
index 469dbd49..526ed496 100644
--- a/src/model/key_table.rs
+++ b/src/model/key_table.rs
@@ -171,4 +171,31 @@ impl TableSchema for KeyTable {
}
}
}
+
+ fn try_migrate(bytes: &[u8]) -> Option<Self::E> {
+ let old_k =
+ match rmp_serde::decode::from_read_ref::<_, garage_model_050::key_table::Key>(bytes) {
+ Ok(x) => x,
+ Err(_) => return None,
+ };
+ let state = if old_k.deleted.get() {
+ crdt::Deletable::Deleted
+ } else {
+ // Authorized buckets is ignored here,
+ // migration is performed in specific migration code in
+ // garage/migrate.rs
+ crdt::Deletable::Present(KeyParams {
+ allow_create_bucket: crdt::Lww::new(false),
+ authorized_buckets: crdt::Map::new(),
+ local_aliases: crdt::LwwMap::new(),
+ })
+ };
+ let name = crdt::Lww::migrate_from_raw(old_k.name.timestamp(), old_k.name.get().clone());
+ Some(Key {
+ key_id: old_k.key_id,
+ secret_key: old_k.secret_key,
+ name,
+ state,
+ })
+ }
}