default impl self-written + config preboot param check fixed

pull/21/head
prplV 2025-01-15 13:17:14 +03:00
parent 5d54c5b97c
commit eed9fa881a
1 changed files with 29 additions and 7 deletions

View File

@ -38,16 +38,34 @@ impl std::fmt::Display for EnvVars {
}
}
impl Default for EnvVars {
fn default() {
todo!()
// setting default env vars values if not exists
// impl<'a> Default for EnvVars {
// fn default() -> &'a str {
// todo!()
// // setting default env vars values if not exists
// }
// }
impl<'a> EnvVars {
// Default trait func is not satisfying this issue
fn default(self) -> &'a str {
match self {
EnvVars::NoxisNoHagent => "false",
EnvVars::NoxisNoLogs => "false",
EnvVars::NoxisRefreshLogs => "false",
EnvVars::NoxisNoRemoteConfig => "false",
EnvVars::NoxisNoConfigSub => "false",
EnvVars::NoxisSocketPath => "/var/run/enode/hostagent.sock",
EnvVars::NoxisLogTo => "./",
EnvVars::NoxisRemoteServerUrl => "localhost",
EnvVars::NoxisConfig => "./settings.json",
EnvVars::NoxisMetrics => "NOXIS_METRICS",
}
}
}
impl EnvVars {
fn setup() {
// setup default if not exists
// check values and save preboot states in env vars if not equal
todo!()
}
}
@ -256,6 +274,10 @@ impl PrebootParams {
// existing sock file
if !self.config.exists() {
eprintln!("Error: Invalid character in config file. Config path was set to default");
let config = PathBuf::from("/etc/settings.json");
if !config.exists() && self.no_remote_config {
return Err(Error::msg("Noxis cannot run without config. Create local config or enable remote-config mechanism"));
}
self.config = PathBuf::from("settings.json");
// return Err(Error::msg("Local Config Not Found or Noxis can't read it. Cannot start"));
}