kinetic/agent/
identity.rs1use anyhow::Result;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct HostIdentity {
8 pub host_id: String,
9 pub realm_id: String,
10 pub token: String,
11}
12
13impl HostIdentity {
14 pub fn load_or_enroll(token: Option<String>) -> Result<Self> {
15 let token = token.ok_or_else(|| anyhow::anyhow!("Authentication token is required for fleet agent mode. Please provide it via configuration or command line."))?;
21
22 Ok(Self {
24 host_id: hostname::get()?.to_string_lossy().to_string(),
25 realm_id: "default".to_string(), token,
27 })
28 }
29}