feat: load ftest control and result repository configs

This commit is contained in:
Aravinth Manivannan 2023-09-29 19:16:00 +05:30
parent 76b7d7e727
commit b3c685b593
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 36 additions and 19 deletions

View file

@ -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"

View file

@ -1,19 +1,8 @@
/*
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
*
* 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 <https://www.gnu.org/licenses/>.
*/
// Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
//
// 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))]