handle flavor atom version range

This commit is contained in:
Aiden McClelland
2025-12-17 14:18:43 -07:00
parent e33ab39b85
commit 6c5179a179
9 changed files with 423 additions and 502 deletions

View File

@@ -35,7 +35,7 @@ pub struct CliContextSeed {
pub base_url: Url,
pub rpc_url: Url,
pub registry_url: Option<Url>,
pub registry_hostname: Option<InternedString>,
pub registry_hostname: Vec<InternedString>,
pub registry_listen: Option<SocketAddr>,
pub tunnel_addr: Option<SocketAddr>,
pub tunnel_listen: Option<SocketAddr>,
@@ -126,7 +126,7 @@ impl CliContext {
Ok::<_, Error>(registry)
})
.transpose()?,
registry_hostname: config.registry_hostname,
registry_hostname: config.registry_hostname.unwrap_or_default(),
registry_listen: config.registry_listen,
tunnel_addr: config.tunnel,
tunnel_listen: config.tunnel_listen,

View File

@@ -65,7 +65,7 @@ pub struct ClientConfig {
#[arg(short = 'r', long)]
pub registry: Option<Url>,
#[arg(long)]
pub registry_hostname: Option<InternedString>,
pub registry_hostname: Option<Vec<InternedString>>,
#[arg(skip)]
pub registry_listen: Option<SocketAddr>,
#[arg(short = 't', long)]

View File

@@ -478,7 +478,7 @@ pub fn make_leaf_cert(
// Google Apple and Mozilla reject certificate horizons longer than 398 days
// https://techbeacon.com/security/google-apple-mozilla-enforce-1-year-max-security-certifications
let expiration = Asn1Time::days_from_now(397)?;
let expiration = Asn1Time::days_from_now(365)?;
builder.set_not_after(&expiration)?;
builder.set_serial_number(&*rand_serial()?)?;

View File

@@ -8,6 +8,7 @@ use clap::Parser;
use http::HeaderMap;
use imbl_value::InternedString;
use patch_db::PatchDb;
use patch_db::json_ptr::ROOT;
use reqwest::{Client, Proxy};
use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{CallRemote, Context, Empty, RpcRequest};
@@ -97,12 +98,12 @@ impl RegistryContext {
tokio::fs::create_dir_all(&datadir).await?;
}
let db_path = datadir.join("registry.db");
let db = TypedPatchDb::<RegistryDatabase>::load_or_init(
PatchDb::open(&db_path).await?,
|| async { Ok(RegistryDatabase::init()) },
)
.await?;
let db = TypedPatchDb::<RegistryDatabase>::load_unchecked(PatchDb::open(&db_path).await?);
if db.dump(&ROOT).await.value.is_null() {
db.put(&ROOT, &RegistryDatabase::init()).await?;
}
db.mutate(|db| run_migrations(db)).await.result?;
let tor_proxy_url = config
.tor_proxy
.clone()
@@ -170,7 +171,7 @@ impl CallRemote<RegistryContext> for CliContext {
) -> Result<Value, RpcError> {
let url = if let Some(url) = self.registry_url.clone() {
url
} else if self.registry_hostname.is_some() {
} else if !self.registry_hostname.is_empty() {
let mut url: Url = format!(
"http://{}",
self.registry_listen.unwrap_or(DEFAULT_REGISTRY_LISTEN)
@@ -191,7 +192,8 @@ impl CallRemote<RegistryContext> for CliContext {
method = method.strip_prefix("registry.").unwrap_or(method);
let sig_context = self
.registry_hostname
.clone()
.get(0)
.cloned()
.or_else(|| url.host().as_ref().map(InternedString::from_display));
crate::middleware::signature::call_remote(

View File

@@ -13,8 +13,9 @@ pub trait RegistryMigration {
pub const MIGRATIONS: &[&dyn RegistryMigration] =
&[&m_00_package_signer_scope::PackageSignerScopeMigration];
#[instrument(skip_all)]
pub fn run_migrations(db: &mut Model<RegistryDatabase>) -> Result<(), Error> {
let mut migrations = db.as_migrations().de()?;
let mut migrations = db.as_migrations().de().unwrap_or_default();
for migration in MIGRATIONS {
if !migrations.contains(migration.name()) {
migration.action(ModelExt::as_value_mut(db))?;