diff options
Diffstat (limited to 'src/endpoint/configured.rs')
-rw-r--r-- | src/endpoint/configured.rs | 39 |
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 { |