diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-03-05 20:06:28 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-07 21:50:29 +0100 |
commit | e09131771c6dbd535cd2f98a1830fb3d9a1bc427 (patch) | |
tree | 7728735ddd5951d3b5e4262d02730b3bfd0742dd /src/endpoint | |
parent | ec4d6eff956eba228c949d3ac178218682c73cdf (diff) |
Add Endpoint::get_container_by_id()
This function returns a shiplift::Container rather than an own type, which is
more convenient at this point, but might be rewritten if we provide more
endpoints (something else than docker).
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/endpoint')
-rw-r--r-- | src/endpoint/configured.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs index ae54dfb..b703a5f 100644 --- a/src/endpoint/configured.rs +++ b/src/endpoint/configured.rs @@ -283,6 +283,19 @@ impl Endpoint { .map(|o| o.is_some()) } + 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() + } } /// Helper type to store endpoint statistics |