Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix migration for alpha.10 #2811

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions core/startos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = [
name = "start-os"
readme = "README.md"
repository = "https://github.com/Start9Labs/start-os"
version = "0.3.6-alpha.10"
version = "0.3.6-alpha.11"
license = "MIT"

[lib]
Expand Down Expand Up @@ -226,7 +226,7 @@ zbus = "5.1.1"
zeroize = "1.6.0"
mail-send = { git = "https://github.com/dr-bonez/mail-send.git", branch = "main" }
rustls = "0.23.20"
rustls-pki-types = { version = "1.10.1", features = ["alloc"]}
rustls-pki-types = { version = "1.10.1", features = ["alloc"] }

[profile.test]
opt-level = 3
Expand Down
8 changes: 7 additions & 1 deletion core/startos/src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use imbl_value::{to_value, InternedString};
use patch_db::json_ptr::ROOT;

use crate::context::RpcContext;
use crate::db::model::Database;
use crate::prelude::*;
use crate::Error;

Expand All @@ -28,8 +29,9 @@ mod v0_3_6_alpha_8;
mod v0_3_6_alpha_9;

mod v0_3_6_alpha_10;
mod v0_3_6_alpha_11;

pub type Current = v0_3_6_alpha_10::Version; // VERSION_BUMP
pub type Current = v0_3_6_alpha_11::Version; // VERSION_BUMP

impl Current {
#[instrument(skip(self, db))]
Expand All @@ -52,6 +54,7 @@ impl Current {
let pre_ups = PreUps::load(&from, &self).await?;
db.apply_function(|mut db| {
migrate_from_unchecked(&from, &self, pre_ups, &mut db)?;
from_value::<Database>(db.clone())?;
Ok::<_, Error>((db, ()))
})
.await?;
Expand Down Expand Up @@ -109,6 +112,7 @@ enum Version {
V0_3_6_alpha_8(Wrapper<v0_3_6_alpha_8::Version>),
V0_3_6_alpha_9(Wrapper<v0_3_6_alpha_9::Version>),
V0_3_6_alpha_10(Wrapper<v0_3_6_alpha_10::Version>),
V0_3_6_alpha_11(Wrapper<v0_3_6_alpha_11::Version>),
Other(exver::Version),
}

Expand Down Expand Up @@ -143,6 +147,7 @@ impl Version {
Self::V0_3_6_alpha_8(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_9(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_10(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_11(v) => DynVersion(Box::new(v.0)),
Self::Other(v) => {
return Err(Error::new(
eyre!("unknown version {v}"),
Expand All @@ -169,6 +174,7 @@ impl Version {
Version::V0_3_6_alpha_8(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_9(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_10(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_11(Wrapper(x)) => x.semver(),
Version::Other(x) => x.clone(),
}
}
Expand Down
83 changes: 83 additions & 0 deletions core/startos/src/version/v0_3_6_alpha_11.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
use exver::{PreReleaseSegment, VersionRange};
use imbl_value::json;

use super::v0_3_5::V0_3_0_COMPAT;
use super::{v0_3_6_alpha_10, VersionT};
use crate::prelude::*;

lazy_static::lazy_static! {
static ref V0_3_6_alpha_11: exver::Version = exver::Version::new(
[0, 3, 6],
[PreReleaseSegment::String("alpha".into()), 11.into()]
);
}

#[derive(Clone, Copy, Debug, Default)]
pub struct Version;

impl VersionT for Version {
type Previous = v0_3_6_alpha_10::Version;
type PreUpRes = ();

async fn pre_up(self) -> Result<Self::PreUpRes, Error> {
Ok(())
}
fn semver(self) -> exver::Version {
V0_3_6_alpha_11.clone()
}
fn compat(self) -> &'static VersionRange {
&V0_3_0_COMPAT
}
fn up(self, db: &mut Value, _: Self::PreUpRes) -> Result<(), Error> {
let acme = std::mem::replace(
&mut db["public"]["serverInfo"]["acme"],
Value::Object(Default::default()),
);
if !acme.is_null() && acme["provider"].as_str().is_some() {
db["public"]["serverInfo"]["acme"]
[&acme["provider"].as_str().or_not_found("provider")?] =
json!({ "contact": &acme["contact"] });
}

for (_, package) in db["public"]["packageData"]
.as_object_mut()
.ok_or_else(|| {
Error::new(
eyre!("expected public.packageData to be an object"),
ErrorKind::Database,
)
})?
.iter_mut()
{
for (_, host) in package["hosts"]
.as_object_mut()
.ok_or_else(|| {
Error::new(
eyre!("expected public.packageData[id].hosts to be an object"),
ErrorKind::Database,
)
})?
.iter_mut()
{
for (_, bind) in host["bindings"]
.as_object_mut()
.ok_or_else(|| {
Error::new(
eyre!("expected public.packageData[id].hosts[hostId].bindings to be an object"),
ErrorKind::Database,
)
})?
.iter_mut()
{
bind["net"] = bind["lan"].clone();
bind["net"]["public"] = Value::Bool(false);
}
}
}

Ok(())
}
fn down(self, _db: &mut Value) -> Result<(), Error> {
Ok(())
}
}
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "startos-ui",
"version": "0.3.6-alpha.10",
"version": "0.3.6-alpha.11",
"author": "Start9 Labs, Inc",
"homepage": "https://start9.com/",
"license": "MIT",
Expand Down