summaryrefslogtreecommitdiffstats
path: root/src/endpoint
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-03-10 08:15:59 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-03-10 08:15:59 +0100
commitfef7675ea06354b7b3102edaffb9eebbd7edfcb1 (patch)
treef89ab395eb5cfdf3bacf4910c4ce05b3ae71a61d /src/endpoint
parent3d363bd203aec1b6ad5c637228cd62811a8a1127 (diff)
Refactor: Simplify impl of Endpoint::get_container_by_id()
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/endpoint')
-rw-r--r--src/endpoint/configured.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index b703a5f..d6139ab 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -284,17 +284,11 @@ impl Endpoint {
}
pub async fn get_container_by_id<'a>(&'a self, id: &str) -> Result<Option<Container<'a>>> {
- self.container_stats()
- .await?
- .iter()
- .find(|st| st.id == id)
- .map(|_| {
- self.docker
- .containers()
- .get(id)
- })
- .map(Ok)
- .transpose()
+ if self.has_container_with_id(id).await? {
+ Ok(Some(self.docker.containers().get(id)))
+ } else {
+ Ok(None)
+ }
}
}