Allow containers to be always cycled
This commit is contained in:
parent
ef358ec35e
commit
afaff012b4
1 changed files with 8 additions and 5 deletions
13
src/main.rs
13
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<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);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue