diff options
Diffstat (limited to 'src/endpoint/configured.rs')
-rw-r--r-- | src/endpoint/configured.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs index 4a0e933..c6c4953 100644 --- a/src/endpoint/configured.rs +++ b/src/endpoint/configured.rs @@ -281,6 +281,24 @@ impl Endpoint { }) } + pub async fn number_of_running_containers(&self) -> Result<usize> { + self.docker + .containers() + .list({ + &shiplift::builder::ContainerListOptions::builder() + .all() + .build() + }) + .await + .map_err(Error::from) + .map(|list| { + list.into_iter() + .inspect(|stat| trace!("stat = {:?}", stat)) + .filter(|stat| stat.state == "running") + .count() + }) + } + pub async fn has_container_with_id(&self, id: &str) -> Result<bool> { self.container_stats() .await? |