1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-04 17:44:11 +02:00

delete orphaned networks

This commit is contained in:
Robin Appelman 2021-08-13 15:39:04 +02:00
commit cbb987065d
2 changed files with 24 additions and 0 deletions

21
src/network.rs Normal file
View file

@ -0,0 +1,21 @@
use bollard::Docker;
use color_eyre::{eyre::WrapErr, Result};
pub async fn clear_networks(docker: &Docker) -> Result<()> {
let networks = docker
.list_networks::<&str>(None)
.await
.wrap_err("Failed to list docker networks")?;
for network in networks {
match network.name.as_deref() {
Some(name) if name.starts_with("haze-") => {
docker
.remove_network(name)
.await
.wrap_err("Failed to remove docker network")?;
}
_ => {}
}
}
Ok(())
}