From b3c685b593d9a79e075acb4ffa2e38aa900c64fd Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Fri, 29 Sep 2023 19:16:00 +0530 Subject: [PATCH] feat: load ftest control and result repository configs --- config/default.toml | 8 +++++++- src/settings.rs | 47 ++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/config/default.toml b/config/default.toml index c5b77d7..de2c5d6 100644 --- a/config/default.toml +++ b/config/default.toml @@ -6,7 +6,7 @@ support_email = "support@forgeflux.org" [server] # The port at which you want Pages to listen to -port = 7000 +port = 9000 #IP address. Enter 0.0.0.0 to listen on all availale addresses ip= "0.0.0.0" # The number of worker threads that must be spun up by the Pages server. @@ -31,3 +31,9 @@ password = "password" name = "postgres" pool = 4 database_type="postgres" # "postgres" + + +[repository] +control_repository = "https://git.batsense.net/ForgeFlux/ftest-control" +results_repository = "ssh://git@git.batsense.net:ForgeFlux/ftest-results" +base_dir = "/tmp/ftest" diff --git a/src/settings.rs b/src/settings.rs index 87dac08..9081abb 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,19 +1,8 @@ -/* - * Copyright (C) 2022 Aravinth Manivannan - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ +// Copyright (C) 2022 Aravinth Manivannan +// SPDX-FileCopyrightText: 2023 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + use std::env; use std::path::Path; @@ -70,6 +59,13 @@ pub struct Database { pub database_type: DBType, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Repository { + pub control_repository: String, + pub results_repository: String, + pub base_dir: String, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Settings { pub allow_registration: bool, @@ -78,6 +74,7 @@ pub struct Settings { pub server: Server, pub source_code: String, pub database: Database, + pub repository: Repository, } #[cfg(not(tarpaulin_include))] @@ -86,7 +83,7 @@ impl Settings { let mut s = Config::builder(); const CURRENT_DIR: &str = "./config/default.toml"; - const ETC: &str = "/etc/liberapages/librepages/config.toml"; + const ETC: &str = "/etc/ftest/config.toml"; let mut read_file = false; @@ -170,7 +167,21 @@ impl Settings { } } - // create_dir_util(Path::new(&self.page.base_path)); + create_dir_util(Path::new(&self.repository.base_dir)); + + let base_dir = Path::new(&self.repository.base_dir); + + let control = base_dir.join("control"); + let results = base_dir.join("results"); + + // check if repo exists, then clone. If exists, pull + + if !control.exists() { + crate::git::Git::clone(&self.repository.control_repository, base_dir, "control"); + } + if !results.exists() { + crate::git::Git::clone(&self.repository.results_repository, base_dir, "results"); + } } #[cfg(not(tarpaulin_include))]