mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
fix config.set
This commit is contained in:
committed by
Aiden McClelland
parent
0cf1a45da7
commit
f848697e99
@@ -23,7 +23,7 @@ fn inner_main() -> Result<(), Error> {
|
|||||||
.takes_value(false),
|
.takes_value(false),
|
||||||
)
|
)
|
||||||
.arg(Arg::with_name("host").long("host").short("h").takes_value(true))
|
.arg(Arg::with_name("host").long("host").short("h").takes_value(true))
|
||||||
.arg(Arg::with_name("port").long("port").short("p").takes_value(true)),
|
.arg(Arg::with_name("proxy").long("proxy").short("p").takes_value(true)),
|
||||||
context: matches => {
|
context: matches => {
|
||||||
simple_logging::log_to_stderr(match matches.occurrences_of("verbosity") {
|
simple_logging::log_to_stderr(match matches.occurrences_of("verbosity") {
|
||||||
0 => log::LevelFilter::Off,
|
0 => log::LevelFilter::Off,
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ pub fn configure<'a, Db: DbHandle>(
|
|||||||
let dependents = pkg_model.clone().current_dependents().get(db, true).await?;
|
let dependents = pkg_model.clone().current_dependents().get(db, true).await?;
|
||||||
let prev = old_config.map(Value::Object).unwrap_or_default();
|
let prev = old_config.map(Value::Object).unwrap_or_default();
|
||||||
let next = Value::Object(config.clone());
|
let next = Value::Object(config.clone());
|
||||||
for (dependent, dep_info) in &*dependents {
|
for (dependent, dep_info) in dependents.iter().filter(|(dep_id, _)| dep_id != &id) {
|
||||||
fn handle_broken_dependents<'a, Db: DbHandle>(
|
fn handle_broken_dependents<'a, Db: DbHandle>(
|
||||||
db: &'a mut Db,
|
db: &'a mut Db,
|
||||||
id: &'a PackageId,
|
id: &'a PackageId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, Read};
|
use std::io::{BufReader, Read};
|
||||||
use std::net::{IpAddr, Ipv4Addr};
|
use std::net::{Ipv4Addr, SocketAddr};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -20,10 +20,8 @@ use crate::{Error, ResultExt};
|
|||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct CliContextConfig {
|
pub struct CliContextConfig {
|
||||||
#[serde(deserialize_with = "deserialize_host")]
|
pub bind_rpc: Option<SocketAddr>,
|
||||||
pub host: Option<Host>,
|
pub host: Option<Url>,
|
||||||
pub port: Option<u16>,
|
|
||||||
pub url: Option<Url>,
|
|
||||||
#[serde(deserialize_with = "crate::util::deserialize_from_str_opt")]
|
#[serde(deserialize_with = "crate::util::deserialize_from_str_opt")]
|
||||||
pub proxy: Option<Url>,
|
pub proxy: Option<Url>,
|
||||||
pub developer_key_path: Option<PathBuf>,
|
pub developer_key_path: Option<PathBuf>,
|
||||||
@@ -69,26 +67,16 @@ impl CliContext {
|
|||||||
} else {
|
} else {
|
||||||
CliContextConfig::default()
|
CliContextConfig::default()
|
||||||
};
|
};
|
||||||
if let Some(bind) = base.server_config.bind_rpc {
|
let url = if let Some(host) = matches.value_of("host") {
|
||||||
if base.host.is_none() {
|
host.parse()?
|
||||||
base.host = Some(match bind.ip() {
|
} else if let Some(host) = base.host {
|
||||||
IpAddr::V4(a) => Host::Ipv4(a),
|
host
|
||||||
IpAddr::V6(a) => Host::Ipv6(a),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if base.port.is_none() {
|
|
||||||
base.port = Some(bind.port())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let host = if let Some(host) = matches.value_of("host") {
|
|
||||||
Some(Host::parse(host).with_kind(crate::ErrorKind::ParseUrl)?)
|
|
||||||
} else {
|
} else {
|
||||||
base.host
|
format!(
|
||||||
};
|
"http://{}",
|
||||||
let port = if let Some(port) = matches.value_of("port") {
|
base.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into())
|
||||||
Some(port.parse()?)
|
)
|
||||||
} else {
|
.parse()?
|
||||||
base.port
|
|
||||||
};
|
};
|
||||||
let proxy = if let Some(proxy) = matches.value_of("proxy") {
|
let proxy = if let Some(proxy) = matches.value_of("proxy") {
|
||||||
Some(proxy.parse()?)
|
Some(proxy.parse()?)
|
||||||
@@ -110,15 +98,7 @@ impl CliContext {
|
|||||||
CookieStore::default()
|
CookieStore::default()
|
||||||
}));
|
}));
|
||||||
Ok(CliContext(Arc::new(CliContextSeed {
|
Ok(CliContext(Arc::new(CliContextSeed {
|
||||||
url: base.url.unwrap_or_else(|| {
|
url,
|
||||||
format!(
|
|
||||||
"http://{}:{}",
|
|
||||||
host.unwrap_or_else(|| DEFAULT_HOST.to_owned()),
|
|
||||||
port.unwrap_or(DEFAULT_PORT)
|
|
||||||
)
|
|
||||||
.parse()
|
|
||||||
.unwrap()
|
|
||||||
}),
|
|
||||||
client: {
|
client: {
|
||||||
let mut builder = Client::builder().cookie_provider(cookie_store.clone());
|
let mut builder = Client::builder().cookie_provider(cookie_store.clone());
|
||||||
if let Some(proxy) = proxy {
|
if let Some(proxy) = proxy {
|
||||||
|
|||||||
@@ -260,10 +260,14 @@ impl DependencyConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_current_dependents<Db: DbHandle>(
|
pub async fn update_current_dependents<
|
||||||
|
'a,
|
||||||
|
Db: DbHandle,
|
||||||
|
I: IntoIterator<Item = (&'a PackageId, &'a CurrentDependencyInfo)>,
|
||||||
|
>(
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
dependent_id: &PackageId,
|
dependent_id: &PackageId,
|
||||||
current_dependencies: &IndexMap<PackageId, CurrentDependencyInfo>,
|
current_dependencies: I,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
for (dependency, dep_info) in current_dependencies {
|
for (dependency, dep_info) in current_dependencies {
|
||||||
if let Some(dependency_model) = crate::db::DatabaseModel::new()
|
if let Some(dependency_model) = crate::db::DatabaseModel::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user