From cdcf6de960d59a3b8ee1148a53a35177df2b09af Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 5 Oct 2020 20:43:58 +0100 Subject: [PATCH] Get a unique set of image hashes running --- src/compose.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compose.rs b/src/compose.rs index e231136..f497040 100644 --- a/src/compose.rs +++ b/src/compose.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use std::path::{Path, PathBuf}; use std::process::Command; @@ -26,4 +27,15 @@ impl ComposeProject { .status() .is_ok() } + + pub fn get_images(&self) -> HashSet { + let output = Command::new("docker-compose") + .current_dir(self.working_directory()) + .args(&["-f", &self.compose_file.to_string_lossy()]) + .args(&["images", "-q"]) + .output() + .expect("Failed to get images"); + let stdout = String::from_utf8(output.stdout).expect("Failed to parse output"); + stdout.trim().split('\n').map(String::from).collect() + } }