From afaff012b4cb4c1991e90595467055a8eb98ec6f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 5 Oct 2020 21:32:35 +0100 Subject: [PATCH] Allow containers to be always cycled --- src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index fab67cd..99749ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,9 @@ struct Opt { #[structopt(short, long)] verbose: bool, + + #[structopt(long)] + force_cycle: bool, } fn get_files(files: &[String]) -> Option> { @@ -32,7 +35,7 @@ fn get_files(files: &[String]) -> Option> { Some(all_files) } -fn do_update(compose_project: compose::ComposeProject) { +fn do_update(compose_project: compose::ComposeProject, force_cycle: bool) { info!("Processing {}...", compose_project); let pre_images = compose_project.get_images(); if pre_images.is_empty() { @@ -44,14 +47,14 @@ fn do_update(compose_project: compose::ComposeProject) { let post_images = compose_project.get_images(); - if post_images == pre_images { - info!("No change to images"); - } else { + if force_cycle || post_images != pre_images { info!("Changes detected - Cycling container"); warn!("Stopping container"); compose_project.down(); warn!("Starting container"); compose_project.up(); + } else { + info!("No change to images"); } } @@ -86,6 +89,6 @@ fn main() { info!("Found {} projects", compose_projects.len()); for compose_project in compose_projects { - do_update(compose_project); + do_update(compose_project, opts.force_cycle); } }