summaryrefslogtreecommitdiffstats
path: root/src/endpoint
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-07-27 16:36:37 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-07-27 16:36:37 +0200
commit69d2334a5121edbbaa7356428e2d6e8fbd5d3443 (patch)
treee99dbdf04ce67123f2339e12e9a67e5345f9c4fc /src/endpoint
parent6c018b14d1ddd2d1d89e62b2e1488ccbcebbaf49 (diff)
parent707898fe04354001130f02a68e1443288d85af3f (diff)
Merge branch 'endpoint-images'
Diffstat (limited to 'src/endpoint')
-rw-r--r--src/endpoint/configured.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index 6a1e3be..e38258c 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -297,6 +297,23 @@ impl Endpoint {
Ok(None)
}
}
+
+ pub async fn images(&self, name_filter: Option<&str>) -> Result<impl Iterator<Item = Image>> {
+ let mut listopts = shiplift::builder::ImageListOptions::builder();
+
+ if let Some(name) = name_filter {
+ listopts.filter_name(name);
+ } else {
+ listopts.all();
+ }
+
+ self.docker
+ .images()
+ .list(&listopts.build())
+ .await
+ .map_err(Error::from)
+ .map(|v| v.into_iter().map(Image::from))
+ }
}
/// Helper type to store endpoint statistics
@@ -358,6 +375,28 @@ impl From<shiplift::rep::Container> for ContainerStat {
}
}
+#[derive(Getters)]
+pub struct Image {
+ #[getset(get = "pub")]
+ created: chrono::DateTime<chrono::Utc>,
+
+ #[getset(get = "pub")]
+ id: String,
+
+ #[getset(get = "pub")]
+ tags: Option<Vec<String>>,
+}
+
+impl From<shiplift::rep::Image> for Image {
+ fn from(img: shiplift::rep::Image) -> Self {
+ Image {
+ created: img.created,
+ id: img.id,
+ tags: img.repo_tags,
+ }
+ }
+}
+
pub struct EndpointHandle(Arc<Endpoint>);
impl EndpointHandle {