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:
parent
c8645f515d
commit
cbb987065d
2 changed files with 24 additions and 0 deletions
21
src/network.rs
Normal file
21
src/network.rs
Normal 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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue