aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-07-09 22:27:43 -0400
committerCara Salter <cara@devcara.com>2022-07-09 22:42:41 -0400
commit5429fcc0859c93da965e91e94e6676c2e6cdd24e (patch)
tree3adda02260db5a63f1b5dec706f39b99b4b6ac4f
parentec087f3d08f5861b6ffcce00a632858a57c86d31 (diff)
downloadsolarlib-5429fcc0859c93da965e91e94e6676c2e6cdd24e.tar.gz
solarlib-5429fcc0859c93da965e91e94e6676c2e6cdd24e.zip
colony: Initial cloud-init support
-rw-r--r--Cargo.toml3
-rw-r--r--src/colony.rs38
-rw-r--r--src/lib.rs2
-rw-r--r--src/ship.rs14
4 files changed, 52 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d0e9dbb..75453ba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "solarlib"
-version = "1.5.0"
+version = "1.6.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -15,6 +15,7 @@ thiserror = "1"
rand = "0.8"
mac_address = "1"
+ulid = { version = "0.6.0", features = ["serde"] }
[dependencies.serde]
version = "1"
diff --git a/src/colony.rs b/src/colony.rs
new file mode 100644
index 0000000..2657fef
--- /dev/null
+++ b/src/colony.rs
@@ -0,0 +1,38 @@
+/*!
+ * A Colony is cloud-init data that can be used to set up a new planet
+ **/
+
+/*
+ * Colonies basically need to store things like any files that need to be created in the VM and
+ * users that should be added. This needs to be serialized into a cloud-init document that can then
+ * (somehow) be thrown into QEMU
+ */
+
+use serde::{Deserialize, Serialize};
+use ulid::Ulid;
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct Colony {
+ pub user_data: UserData,
+ pub meta_data: MetaData,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct UserData {
+ pub users: Vec<User>,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct User {
+ pub name: String,
+ pub groups: Vec<String>,
+ pub ssh_authorized_keys: Vec<String>,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct MetaData {
+ #[serde(rename = "instance-id")]
+ pub instance_id: Ulid,
+ #[serde(rename = "local-hostname")]
+ pub hostname: String
+}
diff --git a/src/lib.rs b/src/lib.rs
index 75e7c77..37ef8f1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,4 +6,6 @@ pub mod star;
pub mod ship;
+pub mod colony;
+
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
diff --git a/src/ship.rs b/src/ship.rs
index 7b684b3..a76ea54 100644
--- a/src/ship.rs
+++ b/src/ship.rs
@@ -39,6 +39,8 @@ pub struct Ship {
pub download_url: String,
/// The commonly accepted version (e.g "rolling", "21.11", "unstable")
pub version: String,
+ /// Whether this ship supports the use of cloud-init (Colonies)
+ pub colonizable: bool
}
/// Describes a starship generated from a database
@@ -50,7 +52,8 @@ pub struct DbShip {
pub name: String,
pub shasum: String,
pub download_url: String,
- pub version: String
+ pub version: String,
+ pub colonizable: bool,
}
impl From<DbShip> for Ship {
@@ -59,7 +62,8 @@ impl From<DbShip> for Ship {
name: o.name,
shasum: Sha256(o.shasum),
download_url: o.download_url,
- version: o.version
+ version: o.version,
+ colonizable: o.colonizable
}
}
}
@@ -68,13 +72,15 @@ impl Ship {
pub fn new(name: String,
shasum: String,
download_url: String,
- version: String
+ version: String,
+ colonizable: bool,
) -> Self {
Self {
name,
shasum: Sha256(shasum),
download_url,
- version
+ version,
+ colonizable
}
}