2025-04-24 08:57:50 +03:00
|
|
|
pub async fn is_docker() -> bool {
|
2025-04-21 18:00:48 +03:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
{
|
|
|
|
|
static CACHE: tokio::sync::OnceCell<bool> =
|
|
|
|
|
tokio::sync::OnceCell::const_new();
|
2025-04-10 06:55:12 +00:00
|
|
|
|
2025-04-21 18:00:48 +03:00
|
|
|
*CACHE
|
2025-05-24 01:31:42 +03:00
|
|
|
.get_or_init(async || {
|
2025-04-21 18:00:48 +03:00
|
|
|
tokio::fs::try_exists("/.dockerenv").await.unwrap_or(false)
|
|
|
|
|
})
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
|
{
|
|
|
|
|
false
|
|
|
|
|
}
|
2025-04-10 06:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
2025-08-10 22:00:30 +03:00
|
|
|
pub fn pretty_error(e: &crate::Error) -> String {
|
2025-04-29 13:06:18 +03:00
|
|
|
e.chain().map(ToString::to_string).collect::<Vec<_>>().join(" \u{2192} ")
|
|
|
|
|
}
|