forked from Deuxfleurs/garage
Implement migration
This commit is contained in:
parent
e1ce2b228a
commit
96388acf23
2 changed files with 17 additions and 5 deletions
|
@ -156,14 +156,15 @@ impl AdminRpcHandler {
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
BucketOperation::Website(query) => {
|
BucketOperation::Website(query) => {
|
||||||
let bucket = self.get_existing_bucket(&query.bucket).await?;
|
/*let bucket = self.get_existing_bucket(&query.bucket).await?;
|
||||||
if query.allow && query.deny {
|
if query.allow && query.deny {
|
||||||
return Err(Error::Message(format!("Website can not be both allowed and denied on a bucket")));
|
return Err(Error::Message(format!("Website can not be both allowed and denied on a bucket")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if query.allow || query.deny {
|
if query.allow || query.deny {
|
||||||
let exposed = query.allow;
|
let exposed = query.allow;
|
||||||
if let BucketState::Present(ak) = bucket.state.get_mut() {
|
if let BucketState::Present(state) = bucket.state.get_mut() {
|
||||||
|
let ak = state.authorized_keys;
|
||||||
let old_ak = ak.take_and_clear();
|
let old_ak = ak.take_and_clear();
|
||||||
ak.merge(&old_ak.update_mutator(
|
ak.merge(&old_ak.update_mutator(
|
||||||
key_id.to_string(),
|
key_id.to_string(),
|
||||||
|
@ -183,9 +184,9 @@ impl AdminRpcHandler {
|
||||||
"Bucket is exposed as a website."
|
"Bucket is exposed as a website."
|
||||||
} else {
|
} else {
|
||||||
"Bucket is not exposed."
|
"Bucket is not exposed."
|
||||||
};
|
};*/
|
||||||
|
|
||||||
Ok(AdminRPC::Ok(msg))
|
Ok(AdminRPC::Ok(/*msg*/"".to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,11 @@ use crate::key_table::PermissionSet;
|
||||||
|
|
||||||
use model010::bucket_table as prev;
|
use model010::bucket_table as prev;
|
||||||
|
|
||||||
|
/// A bucket is a collection of objects
|
||||||
|
///
|
||||||
|
/// Its parameters are not directly accessible as:
|
||||||
|
/// - It must be possible to merge paramaters, hence the use of a LWW CRDT.
|
||||||
|
/// - A bucket has 2 states, Present or Deleted and parameters make sense only if present.
|
||||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct Bucket {
|
pub struct Bucket {
|
||||||
// Primary key
|
// Primary key
|
||||||
|
@ -123,9 +128,15 @@ impl TableSchema for BucketTable {
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let params = BucketParams {
|
||||||
|
authorized_keys: keys,
|
||||||
|
website: crdt::LWW::new(false)
|
||||||
|
};
|
||||||
|
|
||||||
Some(Bucket {
|
Some(Bucket {
|
||||||
name: old.name,
|
name: old.name,
|
||||||
state: crdt::LWW::migrate_from_raw(old.timestamp, BucketState::Present(keys)),
|
state: crdt::LWW::migrate_from_raw(old.timestamp, BucketState::Present(params)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue