diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index 3e907c5803..21c6a1b17f 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -91,8 +91,8 @@ macro_rules! parse_cmdline_param { }; } -impl AgentConfig { - pub fn new() -> AgentConfig { +impl Default for AgentConfig { + fn default() -> Self { AgentConfig { debug_console: false, dev_mode: false, @@ -106,7 +106,9 @@ impl AgentConfig { tracing: tracer::TraceType::Disabled, } } +} +impl AgentConfig { #[instrument] pub fn parse_cmdline(&mut self, file: &str) -> Result<()> { let cmdline = fs::read_to_string(file)?; @@ -371,7 +373,7 @@ mod tests { #[test] fn test_new() { - let config = AgentConfig::new(); + let config: AgentConfig = Default::default(); assert!(!config.debug_console); assert!(!config.dev_mode); assert_eq!(config.log_level, DEFAULT_LOG_LEVEL); @@ -721,7 +723,7 @@ mod tests { let filename = file_path.to_str().expect("failed to create filename"); - let mut config = AgentConfig::new(); + let mut config: AgentConfig = Default::default(); let result = config.parse_cmdline(&filename.to_owned()); assert!(result.is_err()); diff --git a/src/agent/src/main.rs b/src/agent/src/main.rs index 69e6ec1adf..d413651d52 100644 --- a/src/agent/src/main.rs +++ b/src/agent/src/main.rs @@ -80,8 +80,7 @@ const NAME: &str = "kata-agent"; const KERNEL_CMDLINE_FILE: &str = "/proc/cmdline"; lazy_static! { - static ref AGENT_CONFIG: Arc> = - Arc::new(RwLock::new(config::AgentConfig::new())); + static ref AGENT_CONFIG: Arc> = Arc::new(RwLock::new(Default::default())); } #[instrument]