Skip to content

Commit 9da0ee5

Browse files
committed
wip: rename group -> realm
1 parent a0e779f commit 9da0ee5

File tree

28 files changed

+232
-234
lines changed

28 files changed

+232
-234
lines changed

Cargo.lock

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ members = [
1515
"sandpolis-deploy",
1616
"sandpolis-desktop",
1717
"sandpolis-filesystem",
18-
"sandpolis-group",
18+
"sandpolis-realm",
1919
"sandpolis-instance",
2020
"sandpolis-location",
2121
"sandpolis-macros",

sandpolis-agent/src/agent/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ use tracing::info;
148148

149149
use crate::core::database::{Database, Document};
150150
use crate::core::layer::network::{ConnectionCooldown, ServerConnection};
151-
use crate::core::layer::server::group::GroupClientCert;
151+
use crate::core::layer::server::realm::RealmClientCert;
152152
use crate::core::layer::server::ServerAddress;
153153
use crate::CommandLine;
154154

@@ -195,9 +195,9 @@ pub async fn main(args: CommandLine) -> Result<()> {
195195
};
196196

197197
// Import certificate if it's newer than the one in the database
198-
let cert_db: Option<Document<GroupClientCert>> = state.agent.data.get_document("/cert")?;
198+
let cert_db: Option<Document<RealmClientCert>> = state.agent.data.get_document("/cert")?;
199199
let cert = if let Some(path) = args.certificate {
200-
let cert_fs = GroupClientCert::read(path)?;
200+
let cert_fs = RealmClientCert::read(path)?;
201201

202202
match cert_db {
203203
Some(cert_db) => {

sandpolis-core/src/lib.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,42 +216,42 @@ mod test_instance_id {
216216
}
217217
}
218218

219-
/// Groups have unique names and are shared across the entire cluster. Group
219+
/// Realms have unique names and are shared across the entire cluster. Realm
220220
/// names cannot be changed after they are created.
221221
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
222-
pub struct GroupName(String);
222+
pub struct RealmName(String);
223223

224-
impl Default for GroupName {
224+
impl Default for RealmName {
225225
fn default() -> Self {
226226
Self("default".into())
227227
}
228228
}
229229

230-
impl Display for GroupName {
230+
impl Display for RealmName {
231231
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
232232
f.write_str(&self.0)
233233
}
234234
}
235235

236-
impl Deref for GroupName {
236+
impl Deref for RealmName {
237237
type Target = String;
238238

239239
fn deref(&self) -> &Self::Target {
240240
&self.0
241241
}
242242
}
243243

244-
impl FromStr for GroupName {
244+
impl FromStr for RealmName {
245245
type Err = anyhow::Error;
246246

247247
fn from_str(s: &str) -> Result<Self> {
248-
let name = GroupName(s.to_string());
248+
let name = RealmName(s.to_string());
249249
name.validate()?;
250250
Ok(name)
251251
}
252252
}
253253

254-
impl Validate for GroupName {
254+
impl Validate for RealmName {
255255
fn validate(&self) -> Result<(), ValidationErrors> {
256256
if Regex::new("^[a-z0-9]{4,32}$").unwrap().is_match(&self.0) {
257257
Ok(())
@@ -261,36 +261,36 @@ impl Validate for GroupName {
261261
}
262262
}
263263

264-
impl ToKey for GroupName {
264+
impl ToKey for RealmName {
265265
fn to_key(&self) -> native_db::Key {
266266
native_db::Key::new(self.0.as_bytes().to_vec())
267267
}
268268

269269
fn key_names() -> Vec<String> {
270-
vec!["GroupName".to_string()]
270+
vec!["RealmName".to_string()]
271271
}
272272
}
273273

274274
#[cfg(test)]
275-
mod test_group_name {
275+
mod test_realm_name {
276276
use super::*;
277277

278278
#[test]
279279
fn test_valid() {
280-
assert!("test".parse::<GroupName>().is_ok());
281-
assert!("1default".parse::<GroupName>().is_ok());
282-
assert!("default".parse::<GroupName>().is_ok());
283-
assert!("default99".parse::<GroupName>().is_ok());
280+
assert!("test".parse::<RealmName>().is_ok());
281+
assert!("1default".parse::<RealmName>().is_ok());
282+
assert!("default".parse::<RealmName>().is_ok());
283+
assert!("default99".parse::<RealmName>().is_ok());
284284
}
285285

286286
#[test]
287287
fn test_invalid() {
288-
assert!("t".parse::<GroupName>().is_err());
289-
assert!("".parse::<GroupName>().is_err());
290-
assert!("test*".parse::<GroupName>().is_err());
288+
assert!("t".parse::<RealmName>().is_err());
289+
assert!("".parse::<RealmName>().is_err());
290+
assert!("test*".parse::<RealmName>().is_err());
291291
assert!(
292292
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
293-
.parse::<GroupName>()
293+
.parse::<RealmName>()
294294
.is_err()
295295
);
296296
}

sandpolis-database/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use native_db::transaction::RTransaction;
99
use native_db::transaction::query::SecondaryScanIterator;
1010
use native_db::watch::Event;
1111
use native_db::{Key, Models, ToInput, ToKey};
12-
use sandpolis_core::{GroupName, InstanceId};
12+
use sandpolis_core::{RealmName, InstanceId};
1313
use serde::{Deserialize, Serialize};
1414
use std::collections::{BTreeMap, HashMap};
1515
use std::ops::Range;
@@ -27,7 +27,7 @@ pub mod config;
2727
pub struct DatabaseLayer {
2828
config: DatabaseConfig,
2929
models: &'static Models,
30-
inner: Arc<RwLock<HashMap<Option<GroupName>, Arc<native_db::Database<'static>>>>>,
30+
inner: Arc<RwLock<HashMap<Option<RealmName>, Arc<native_db::Database<'static>>>>>,
3131
}
3232

3333
impl DatabaseLayer {
@@ -49,37 +49,37 @@ impl DatabaseLayer {
4949
})
5050
}
5151

52-
/// Load or create a new database for the given group.
53-
pub async fn add_group(
52+
/// Load or create a new database for the given realm.
53+
pub async fn add_realm(
5454
&mut self,
55-
name: GroupName,
55+
name: RealmName,
5656
) -> Result<Arc<native_db::Database<'static>>> {
5757
// Check for duplicates
5858
let mut inner = self.inner.write().await;
5959
if inner.contains_key(&Some(name.clone())) {
60-
bail!("Duplicate group");
60+
bail!("Duplicate realm");
6161
}
6262

6363
let db = if let Some(path) = self.config.get_storage_dir()? {
6464
let path = path.join(format!("{name}.db"));
6565

66-
debug!(group = %name, path = %path.display(), "Initializing persistent group database");
66+
debug!(realm = %name, path = %path.display(), "Initializing persistent realm database");
6767
Arc::new(native_db::Builder::new().create(self.models, path)?)
6868
} else {
69-
debug!(group = %name, "Initializing ephemeral group database");
69+
debug!(realm = %name, "Initializing ephemeral realm database");
7070
Arc::new(native_db::Builder::new().create_in_memory(self.models)?)
7171
};
7272
inner.insert(Some(name), db.clone());
7373

7474
Ok(db)
7575
}
7676

77-
pub async fn get(&self, name: Option<GroupName>) -> Result<Arc<native_db::Database<'static>>> {
77+
pub async fn get(&self, name: Option<RealmName>) -> Result<Arc<native_db::Database<'static>>> {
7878
let inner = self.inner.read().await;
7979
if let Some(db) = inner.get(&name) {
8080
return Ok(db.clone());
8181
}
82-
bail!("Group not found");
82+
bail!("Realm not found");
8383
}
8484
}
8585

@@ -330,7 +330,7 @@ mod test_database {
330330
},
331331
models,
332332
)?;
333-
database.add_group("default".parse()?).await?;
333+
database.add_realm("default".parse()?).await?;
334334

335335
let db = database.get(Some("default".parse()?)).await?;
336336
let watch: Watch<TestData> = Watch::singleton(db.clone())?;

sandpolis-deploy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tracing = { workspace = true }
1111
os_info = { workspace = true }
1212
russh = { workspace = true, optional = true }
1313
sandpolis-core = { path = "../sandpolis-core", version = "0.0.1" }
14-
sandpolis-group = { path = "../sandpolis-group", version = "0.0.1" }
14+
sandpolis-realm = { path = "../sandpolis-realm", version = "0.0.1" }
1515
sandpolis-macros = { path = "../sandpolis-macros", version = "0.0.1" }
1616

1717
[features]

sandpolis-deploy/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
//! install themselves on first execution. If an agent is already installed,
33
//! the deployer overwrites the existing instance.
44
//!
5-
//! Group certificates and configuration are embedded into the application for a
5+
//! Realm certificates and configuration are embedded into the application for a
66
//! seamless install.
77
8-
use sandpolis_core::GroupName;
8+
use sandpolis_core::RealmName;
99

1010
pub enum SshCredentials {
1111
Password(String),
@@ -19,7 +19,7 @@ pub enum DeployTarget {
1919
}
2020

2121
pub struct DeployConfig {
22-
group: GroupName,
22+
realm: RealmName,
2323
// message LoopConfig {
2424

2525
// // One or more network targets
@@ -60,7 +60,7 @@ pub struct DeployConfig {
6060
// bool memory = 14;
6161
}
6262

63-
// Request to build an agent for the given group.
63+
// Request to build an agent for the given realm.
6464
pub struct BuildAgentRequest(DeployConfig);
6565

6666
enum BuildDeployerResponse {

sandpolis-deploy/src/messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub struct CreateDeployerRequest {
22
pub target: String,
33
pub features: Vec<String>,
4-
pub group: GroupName,
4+
pub realm: RealmName,
55
}

sandpolis-filesystem/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fuser = { version = "0.15.1", optional = true, features = ["serializable"] }
1414
notify = { version = "8.0.0", optional = true }
1515
tracing = { workspace = true }
1616
sandpolis-network = { path = "../sandpolis-network", version = "0.0.1" }
17-
sandpolis-group = { path = "../sandpolis-group", version = "0.0.1" }
17+
sandpolis-realm = { path = "../sandpolis-realm", version = "0.0.1" }
1818
sandpolis-core = { path = "../sandpolis-core", version = "0.0.1" }
1919

2020
[features]

0 commit comments

Comments
 (0)