pull and (TODO) build and (TODO) push
This commit is contained in:
+16
-2
@@ -4,12 +4,13 @@ use dirs::config_dir;
|
||||
|
||||
#[macro_use] extern crate rocket;
|
||||
|
||||
mod build;
|
||||
mod config;
|
||||
|
||||
use config::read_config;
|
||||
use rocket::{State, http::Status};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::{build::{BuildError, pull_or_clone_and_build_and_push}, config::Config};
|
||||
|
||||
const BIN_NAME: &str = "build-joeac";
|
||||
|
||||
@@ -30,7 +31,20 @@ fn index(remote_git_repo: PathBuf, config: &State<Config>) -> (Status, String) {
|
||||
None => (Status::BadRequest, format!("Failed to convert request path to unicode: {:?}", remote_git_repo)),
|
||||
Some(remote_git_repo) => match config.repositories.iter().find(|repo| repo.remote_git_repo.eq(remote_git_repo)) {
|
||||
None => (Status::NotFound, format!("Remote git repository not configured: {remote_git_repo}")),
|
||||
Some(repo) => (Status::Ok, format!("Matched! {:?}", repo))
|
||||
Some(repo) => match pull_or_clone_and_build_and_push(repo) {
|
||||
Err(BuildError::FailedToOpenOrClone(open_err, clone_err)) => (
|
||||
Status::InternalServerError,
|
||||
format!(
|
||||
"Failed to open or clone git repository. Error opening: {:#?}\n\nError cloning: {:#?}",
|
||||
open_err,
|
||||
clone_err)
|
||||
),
|
||||
Err(BuildError::FailedToPull(err)) => (
|
||||
Status::InternalServerError,
|
||||
format!("Failed to pull git repository. Error: {:#?}", err),
|
||||
),
|
||||
Ok(()) => (Status::Ok, String::from("Pulled, built and pushed image")),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user