mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
show proxy addr for ldap-admin in startup message
This commit is contained in:
parent
e76678ec14
commit
88a4100340
4 changed files with 26 additions and 9 deletions
|
|
@ -493,6 +493,7 @@ impl Cloud {
|
||||||
containers.push(container);
|
containers.push(container);
|
||||||
|
|
||||||
let options_clone = options.clone();
|
let options_clone = options.clone();
|
||||||
|
let proxy_config = config.proxy.clone();
|
||||||
let cloud_id = id.clone();
|
let cloud_id = id.clone();
|
||||||
let docker_clone = docker.clone();
|
let docker_clone = docker.clone();
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
|
|
@ -506,7 +507,10 @@ impl Cloud {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for service in options_clone.services {
|
for service in options_clone.services {
|
||||||
match service.start_message(&docker_clone, &cloud_id).await {
|
match service
|
||||||
|
.start_message(&docker_clone, &cloud_id, &proxy_config)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(Some(msg)) => {
|
Ok(Some(msg)) => {
|
||||||
println!("{}", msg);
|
println!("{}", msg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ fn load_secret(name: &str, path: Option<String>, raw: Option<String>) -> Result<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Debug)]
|
#[derive(Default, Deserialize, Debug, Clone)]
|
||||||
pub struct ProxyConfig {
|
pub struct ProxyConfig {
|
||||||
pub listen: String,
|
pub listen: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ mod sharded;
|
||||||
mod smb;
|
mod smb;
|
||||||
|
|
||||||
use crate::cloud::CloudOptions;
|
use crate::cloud::CloudOptions;
|
||||||
use crate::config::{HazeConfig, Preset};
|
use crate::config::{HazeConfig, Preset, ProxyConfig};
|
||||||
pub use crate::service::clam::{Clam, ClamIcap, ClamIcapTls, ClamSocket};
|
pub use crate::service::clam::{Clam, ClamIcap, ClamIcapTls, ClamSocket};
|
||||||
use crate::service::dav::Dav;
|
use crate::service::dav::Dav;
|
||||||
use crate::service::imaginary::Imaginary;
|
use crate::service::imaginary::Imaginary;
|
||||||
|
|
@ -78,7 +78,12 @@ pub trait ServiceTrait {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start_message(&self, _docker: &Docker, _cloud_id: &str) -> Result<Option<String>> {
|
async fn start_message(
|
||||||
|
&self,
|
||||||
|
_docker: &Docker,
|
||||||
|
_cloud_id: &str,
|
||||||
|
_proxy: &ProxyConfig,
|
||||||
|
) -> Result<Option<String>> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::cloud::CloudOptions;
|
use crate::cloud::CloudOptions;
|
||||||
use crate::config::HazeConfig;
|
use crate::config::{HazeConfig, ProxyConfig};
|
||||||
use crate::image::pull_image;
|
use crate::image::pull_image;
|
||||||
use crate::service::ServiceTrait;
|
use crate::service::ServiceTrait;
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
@ -9,6 +9,8 @@ use bollard::query_parameters::CreateContainerOptions;
|
||||||
use bollard::Docker;
|
use bollard::Docker;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use miette::{IntoDiagnostic, Report};
|
use miette::{IntoDiagnostic, Report};
|
||||||
|
use std::net::IpAddr;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Ldap;
|
pub struct Ldap;
|
||||||
|
|
@ -151,9 +153,15 @@ impl ServiceTrait for LdapAdmin {
|
||||||
Some(format!("{}-ldap-admin", cloud_id))
|
Some(format!("{}-ldap-admin", cloud_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start_message(&self, docker: &Docker, cloud_id: &str) -> Result<Option<String>> {
|
async fn start_message(
|
||||||
|
&self,
|
||||||
|
docker: &Docker,
|
||||||
|
cloud_id: &str,
|
||||||
|
proxy: &ProxyConfig,
|
||||||
|
) -> Result<Option<String>> {
|
||||||
|
let id = self.container_name(cloud_id).unwrap();
|
||||||
let info = docker
|
let info = docker
|
||||||
.inspect_container(&self.container_name(cloud_id).unwrap(), None)
|
.inspect_container(&id, None)
|
||||||
.await
|
.await
|
||||||
.into_diagnostic()?;
|
.into_diagnostic()?;
|
||||||
let ip = if matches!(
|
let ip = if matches!(
|
||||||
|
|
@ -176,9 +184,9 @@ impl ServiceTrait for LdapAdmin {
|
||||||
} else {
|
} else {
|
||||||
return Err(Report::msg("ldap admin not started"));
|
return Err(Report::msg("ldap admin not started"));
|
||||||
};
|
};
|
||||||
|
let addr = proxy.addr(&id, IpAddr::from_str(&ip).unwrap());
|
||||||
Ok(Some(format!(
|
Ok(Some(format!(
|
||||||
"Ldap admin running at: https://{} with 'cn=admin,dc=example,dc=org' and password 'haze'",
|
"Ldap admin running at: {addr} with 'cn=admin,dc=example,dc=org' and password 'haze'"
|
||||||
ip
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue