Skip to content

Commit 29d0797

Browse files
committed
fix(cli): read L0 identity from config in JSON mode
The `identity --json` path was reading L0 facts from the identity_facts table (tier=0), which is never populated. L0 data (name, role, vault_purpose) lives in config.toml. Now the JSON output mirrors the non-JSON path by reading from config.
1 parent 10336a3 commit 29d0797

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,21 @@ async fn main() -> Result<()> {
616616
}
617617
}
618618
if json {
619-
let l0 = store.get_identity_facts(0)?;
619+
// L0 comes from config (not the identity_facts table)
620+
let id = &cfg.identity;
621+
let mut l0_entries = Vec::new();
622+
if let Some(name) = &id.name {
623+
l0_entries.push(serde_json::json!({"key": "name", "value": name}));
624+
}
625+
if let Some(role) = &id.role {
626+
l0_entries.push(serde_json::json!({"key": "role", "value": role}));
627+
}
628+
if let Some(purpose) = &id.vault_purpose {
629+
l0_entries.push(serde_json::json!({"key": "vault_purpose", "value": purpose}));
630+
}
620631
let l1 = store.get_identity_facts(1)?;
621632
let result = serde_json::json!({
622-
"l0": l0.iter().map(|f| serde_json::json!({"key": &f.key, "value": &f.value})).collect::<Vec<_>>(),
633+
"l0": l0_entries,
623634
"l1": l1.iter().map(|f| serde_json::json!({"key": &f.key, "value": &f.value, "source": &f.source, "updated_at": &f.updated_at})).collect::<Vec<_>>(),
624635
});
625636
println!("{}", serde_json::to_string_pretty(&result)?);

0 commit comments

Comments
 (0)