1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-10-01 08:44:09 +02:00

add haze env

This commit is contained in:
Robin Appelman 2023-03-20 20:36:44 +01:00
commit 2a587c0c7e
4 changed files with 85 additions and 1 deletions

View file

@ -6,6 +6,7 @@ use bollard::Docker;
use maplit::hashmap;
use miette::{IntoDiagnostic, Report, Result, WrapErr};
use std::io::{stdout, Stdout};
use std::net::IpAddr;
use std::str::FromStr;
use std::time::Duration;
use tokio::time::{sleep, timeout};
@ -294,6 +295,24 @@ impl Database {
.wrap_err("Timeout after 15 seconds")?
}
pub async fn ip(&self, docker: &mut Docker, cloud_id: &str) -> Option<IpAddr> {
match self.family() {
DatabaseFamily::Sqlite => return None,
_ => docker
.inspect_container(&format!("{}-db", cloud_id), None)
.await
.ok()?
.network_settings?
.networks?
.values()
.next()?
.ip_address
.clone()?
.parse()
.ok(),
}
}
async fn is_healthy(&self, docker: &mut Docker, cloud_id: &str) -> Result<bool> {
match self.family() {
DatabaseFamily::Sqlite => Ok(true),