From ec4d6eff956eba228c949d3ac178218682c73cdf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 5 Mar 2021 20:06:16 +0100 Subject: Add Endpoint::has_container_with_id() Signed-off-by: Matthias Beyer --- src/endpoint/configured.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/endpoint') diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs index 454850d..ae54dfb 100644 --- a/src/endpoint/configured.rs +++ b/src/endpoint/configured.rs @@ -272,6 +272,17 @@ impl Endpoint { .collect() }) } + + pub async fn has_container_with_id(&self, id: &str) -> Result { + self.container_stats() + .await? + .iter() + .find(|st| st.id == id) + .map(Ok) + .transpose() + .map(|o| o.is_some()) + } + } /// Helper type to store endpoint statistics -- cgit v1.2.3