Allow containers to be pulled
This commit is contained in:
parent
790d163de0
commit
394d7ac3e1
2 changed files with 18 additions and 13 deletions
|
@ -1,6 +1,5 @@
|
||||||
use std::io::Result;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Command, Output};
|
use std::process::Command;
|
||||||
|
|
||||||
pub struct ComposeProject {
|
pub struct ComposeProject {
|
||||||
compose_file: PathBuf,
|
compose_file: PathBuf,
|
||||||
|
@ -19,16 +18,12 @@ impl ComposeProject {
|
||||||
.expect("Failed to get parent of compose file")
|
.expect("Failed to get parent of compose file")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_in_dir(&self, command: &str, arguments: &[&str]) -> Result<Output> {
|
pub fn pull(&self) -> bool {
|
||||||
Command::new(command)
|
Command::new("docker-compose")
|
||||||
.current_dir(self.working_directory())
|
.current_dir(self.working_directory())
|
||||||
.args(arguments)
|
.args(&["-f", &self.compose_file.to_string_lossy()])
|
||||||
.output()
|
.arg("pull")
|
||||||
}
|
.status()
|
||||||
|
.is_ok()
|
||||||
fn docker_compose(&self, arguments: &[&str])-> Result<Output> {
|
|
||||||
let mut compose_arguments = vec!["-f", self.compose_file.to_str().expect("Path parse failed")];
|
|
||||||
compose_arguments.extend_from_slice(arguments);
|
|
||||||
self.execute_in_dir("docker-compose", compose_arguments.as_slice())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -22,7 +22,9 @@ fn get_files(files: &[String]) -> Option<Vec<PathBuf>> {
|
||||||
for file in files {
|
for file in files {
|
||||||
for path in glob(&file).ok()?.filter_map(Result::ok) {
|
for path in glob(&file).ok()?.filter_map(Result::ok) {
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
all_files.push(path);
|
if let Ok(canonical_path) = path.canonicalize() {
|
||||||
|
all_files.push(canonical_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +32,10 @@ fn get_files(files: &[String]) -> Option<Vec<PathBuf>> {
|
||||||
Some(all_files)
|
Some(all_files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn do_update(compose_project: compose::ComposeProject) {
|
||||||
|
compose_project.pull();
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let opts = Opt::from_args();
|
let opts = Opt::from_args();
|
||||||
env_logger::builder()
|
env_logger::builder()
|
||||||
|
@ -59,4 +65,8 @@ fn main() {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
info!("Found {} projects", compose_projects.len());
|
info!("Found {} projects", compose_projects.len());
|
||||||
|
|
||||||
|
for compose_project in compose_projects {
|
||||||
|
do_update(compose_project);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue