1
Fork 0

Allow containers to be always cycled

This commit is contained in:
Jake Howard 2020-10-05 21:32:35 +01:00
parent ef358ec35e
commit afaff012b4
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -15,6 +15,9 @@ struct Opt {
#[structopt(short, long)]
verbose: bool,
#[structopt(long)]
force_cycle: bool,
}
fn get_files(files: &[String]) -> Option<Vec<PathBuf>> {
@ -32,7 +35,7 @@ fn get_files(files: &[String]) -> Option<Vec<PathBuf>> {
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);
}
}