Skip to content

Commit c0a2231

Browse files
committed
config: Add configuration file version
This is not currently used, but will be important in future to check configuration file compatibility and upgrades. Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
1 parent 0d86b83 commit c0a2231

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

keylime-agent.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
[agent]
33
#=============================================================================
44

5+
# The configuration file version
6+
version = "2.0"
7+
58
# The agent's UUID.
69
# Set to "openstack", it will try to get the UUID from the metadata service.
710
# If you set this to "generate", Keylime will create a random UUID.

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::{
2020
use toml::value::Table;
2121
use uuid::Uuid;
2222

23+
pub static CONFIG_VERSION: &str = "2.0";
2324
pub static DEFAULT_UUID: &str = "d432fbb3-d2f1-4a97-9ef7-75bd81c00000";
2425
pub static DEFAULT_IP: &str = "127.0.0.1";
2526
pub static DEFAULT_PORT: u32 = 9002;
@@ -63,6 +64,7 @@ pub static DEFAULT_CONFIG_SYS: &str = "/usr/etc/keylime-agent.conf";
6364
impl Source for KeylimeConfig {
6465
fn collect(&self) -> Result<Map<String, Value>, ConfigError> {
6566
let agent: Map<String, Value> = Map::from([
67+
("version".to_string(), self.agent.version.to_string().into()),
6668
("uuid".to_string(), self.agent.uuid.to_string().into()),
6769
("ip".to_string(), self.agent.ip.to_string().into()),
6870
("port".to_string(), Value::from(self.agent.port)),
@@ -263,6 +265,7 @@ pub(crate) struct KeylimeConfig {
263265

264266
#[derive(Clone, Debug, Deserialize, Serialize)]
265267
pub(crate) struct AgentConfig {
268+
pub version: String,
266269
pub uuid: String,
267270
pub ip: String,
268271
pub port: u32,
@@ -308,6 +311,7 @@ impl Default for AgentConfig {
308311
};
309312

310313
AgentConfig {
314+
version: CONFIG_VERSION.to_string(),
311315
ip: DEFAULT_IP.to_string(),
312316
port: DEFAULT_PORT,
313317
registrar_ip: DEFAULT_REGISTRAR_IP.to_string(),

0 commit comments

Comments
 (0)