refactor: update meta plugin to use output mappings

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-19 12:57:06 -03:00
parent 1659bf20d4
commit 58ecbd63cf
7 changed files with 386 additions and 58 deletions

View File

@@ -11,7 +11,7 @@ pub struct BinaryMetaPlugin {
max_buffer_size: usize,
is_saved: bool,
item_id: Option<i64>,
output_names: std::collections::HashMap<String, String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl BinaryMetaPlugin {
@@ -22,7 +22,7 @@ impl BinaryMetaPlugin {
max_buffer_size: 4096, // 4KB
is_saved: false,
item_id: None,
output_names: std::collections::HashMap::new(),
outputs: std::collections::HashMap::new(),
}
}
@@ -33,7 +33,7 @@ impl BinaryMetaPlugin {
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
// Save to database immediately using central output handler
let _ = output_metadata(conn, item_id, &self.meta_name, value, &self.output_names);
let _ = self.save_meta(conn, item_id, "binary", value);
self.is_saved = true;
}
@@ -93,8 +93,8 @@ impl MetaPlugin for BinaryMetaPlugin {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let (Some(key_str), Some(value_str)) = (key.as_str(), value.as_str()) {
self.output_names.insert(key_str.to_string(), value_str.to_string());
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
@@ -102,7 +102,11 @@ impl MetaPlugin for BinaryMetaPlugin {
Ok(())
}
fn get_output_name(&self, default_name: &str) -> String {
self.output_names.get(default_name).cloned().unwrap_or_else(|| default_name.to_string())
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}

View File

@@ -10,7 +10,7 @@ pub struct DigestSha256MetaPlugin {
hasher: Sha256,
meta_name: String,
item_id: Option<i64>,
output_names: std::collections::HashMap<String, String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl DigestSha256MetaPlugin {
@@ -19,7 +19,7 @@ impl DigestSha256MetaPlugin {
hasher: Sha256::new(),
meta_name: "digest_sha256".to_string(),
item_id: None,
output_names: std::collections::HashMap::new(),
outputs: std::collections::HashMap::new(),
}
}
}
@@ -41,7 +41,7 @@ impl MetaPlugin for DigestSha256MetaPlugin {
let hex_string = format!("{:x}", hash_result);
// Save the hash as metadata using central output handler
let _ = output_metadata(conn, item_id, &self.meta_name, hex_string, &self.output_names);
let _ = self.save_meta(conn, item_id, "digest_sha256", hex_string);
}
Ok(())
}
@@ -58,8 +58,8 @@ impl MetaPlugin for DigestSha256MetaPlugin {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let (Some(key_str), Some(value_str)) = (key.as_str(), value.as_str()) {
self.output_names.insert(key_str.to_string(), value_str.to_string());
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
@@ -67,8 +67,12 @@ impl MetaPlugin for DigestSha256MetaPlugin {
Ok(())
}
fn get_output_name(&self, default_name: &str) -> String {
self.output_names.get(default_name).cloned().unwrap_or_else(|| default_name.to_string())
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
@@ -77,6 +81,7 @@ impl MetaPlugin for DigestSha256MetaPlugin {
pub struct ReadTimeMetaPlugin {
start_time: Option<Instant>,
meta_name: String,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ReadTimeMetaPlugin {
@@ -84,6 +89,7 @@ impl ReadTimeMetaPlugin {
ReadTimeMetaPlugin {
start_time: None,
meta_name: "read_time".to_string(),
outputs: std::collections::HashMap::new(),
}
}
}
@@ -106,6 +112,27 @@ impl MetaPlugin for ReadTimeMetaPlugin {
fn meta_name(&mut self) -> String {
self.meta_name.clone()
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
@@ -113,6 +140,7 @@ pub struct ReadRateMetaPlugin {
start_time: Option<Instant>,
bytes_read: u64,
meta_name: String,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ReadRateMetaPlugin {
@@ -121,6 +149,7 @@ impl ReadRateMetaPlugin {
start_time: None,
bytes_read: 0,
meta_name: "read_rate".to_string(),
outputs: std::collections::HashMap::new(),
}
}
}
@@ -144,4 +173,25 @@ impl MetaPlugin for ReadRateMetaPlugin {
fn meta_name(&mut self) -> String {
self.meta_name.clone()
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}

View File

@@ -12,7 +12,7 @@ pub struct MagicFileMetaPlugin {
is_saved: bool,
item_id: Option<i64>,
cookie: Option<Cookie>,
output_names: std::collections::HashMap<String, String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl MagicFileMetaPlugin {
@@ -23,7 +23,7 @@ impl MagicFileMetaPlugin {
is_saved: false,
item_id: None,
cookie: None,
output_names: std::collections::HashMap::new(),
outputs: std::collections::HashMap::new(),
}
}
@@ -56,10 +56,22 @@ impl MagicFileMetaPlugin {
fn save_all_magic_metadata(&mut self, conn: &Connection) -> Result<()> {
if let Some(item_id) = self.item_id {
// Only save MIME type since that's what's mapped in the config
// Save all three magic outputs: mime_type, mime_encoding, and file_type
if let Ok(mime_type) = self.get_magic_result(CookieFlags::MIME_TYPE) {
if !mime_type.is_empty() {
let _ = output_metadata(conn, item_id, "mime_type", mime_type, &self.output_names);
let _ = self.save_meta(conn, item_id, "mime_type", mime_type);
}
}
if let Ok(mime_encoding) = self.get_magic_result(CookieFlags::MIME_ENCODING) {
if !mime_encoding.is_empty() {
let _ = self.save_meta(conn, item_id, "mime_encoding", mime_encoding);
}
}
if let Ok(file_type) = self.get_magic_result(CookieFlags::default()) {
if !file_type.is_empty() {
let _ = self.save_meta(conn, item_id, "file_type", file_type);
}
}
@@ -121,8 +133,8 @@ impl MetaPlugin for MagicFileMetaPlugin {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let (Some(key_str), Some(value_str)) = (key.as_str(), value.as_str()) {
self.output_names.insert(key_str.to_string(), value_str.to_string());
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
@@ -137,8 +149,12 @@ impl MetaPlugin for MagicFileMetaPlugin {
Ok(())
}
fn get_output_name(&self, default_name: &str) -> String {
self.output_names.get(default_name).cloned().unwrap_or_else(|| default_name.to_string())
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}

View File

@@ -17,6 +17,7 @@ pub struct MetaPluginProgram {
writer: Option<Box<dyn Write>>,
item_id: Option<i64>,
result: Option<String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl std::fmt::Debug for MetaPluginProgram {
@@ -29,6 +30,7 @@ impl std::fmt::Debug for MetaPluginProgram {
.field("split_whitespace", &self.split_whitespace)
.field("process", &self.process)
.field("writer", &"Box<dyn Write>")
.field("outputs", &self.outputs)
.finish()
}
}
@@ -48,6 +50,7 @@ impl MetaPluginProgram {
writer: None,
item_id: None,
result: None,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -115,12 +118,7 @@ impl MetaPlugin for MetaPluginProgram {
// Save the result to database if we have item_id
if let Some(item_id) = self.item_id {
let meta = crate::db::Meta {
id: item_id,
name: self.meta_name.clone(),
value: self.result.clone().unwrap(),
};
let _ = crate::db::store_meta(conn, meta);
let _ = self.save_meta(conn, item_id, &self.meta_name.clone(), self.result.clone().unwrap());
}
}
} else {
@@ -153,4 +151,25 @@ impl MetaPlugin for MetaPluginProgram {
None
}
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}

View File

@@ -13,7 +13,7 @@ use crate::meta_plugin::{MetaPlugin, output_metadata};
pub struct CwdMetaPlugin {
meta_name: String,
is_saved: bool,
output_names: std::collections::HashMap<String, String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl CwdMetaPlugin {
@@ -21,7 +21,7 @@ impl CwdMetaPlugin {
CwdMetaPlugin {
meta_name: "cwd".to_string(),
is_saved: false,
output_names: std::collections::HashMap::new(),
outputs: std::collections::HashMap::new(),
}
}
}
@@ -50,7 +50,7 @@ impl MetaPlugin for CwdMetaPlugin {
Err(_) => "unknown".to_string(),
};
// Use central output handler
output_metadata(conn, item_id, &self.meta_name, cwd, &self.output_names)?;
self.save_meta(conn, item_id, "cwd", cwd)?;
self.is_saved = true;
Ok(())
}
@@ -59,8 +59,8 @@ impl MetaPlugin for CwdMetaPlugin {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let (Some(key_str), Some(value_str)) = (key.as_str(), value.as_str()) {
self.output_names.insert(key_str.to_string(), value_str.to_string());
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
@@ -68,8 +68,12 @@ impl MetaPlugin for CwdMetaPlugin {
Ok(())
}
fn get_output_name(&self, default_name: &str) -> String {
self.output_names.get(default_name).cloned().unwrap_or_else(|| default_name.to_string())
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
@@ -77,6 +81,7 @@ impl MetaPlugin for CwdMetaPlugin {
pub struct UidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl UidMetaPlugin {
@@ -84,6 +89,7 @@ impl UidMetaPlugin {
UidMetaPlugin {
meta_name: "uid".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -108,16 +114,38 @@ impl MetaPlugin for UidMetaPlugin {
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
let uid = get_current_uid().to_string();
self.save_meta(conn, item_id, uid)?;
self.save_meta(conn, item_id, "uid", uid)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct UserMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl UserMetaPlugin {
@@ -125,6 +153,7 @@ impl UserMetaPlugin {
UserMetaPlugin {
meta_name: "user".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -152,16 +181,38 @@ impl MetaPlugin for UserMetaPlugin {
Some(username) => username.to_string_lossy().to_string(),
None => "unknown".to_string(),
};
self.save_meta(conn, item_id, user)?;
self.save_meta(conn, item_id, "user", user)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct GidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl GidMetaPlugin {
@@ -169,6 +220,7 @@ impl GidMetaPlugin {
GidMetaPlugin {
meta_name: "gid".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -193,16 +245,38 @@ impl MetaPlugin for GidMetaPlugin {
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
let gid = get_current_gid().to_string();
self.save_meta(conn, item_id, gid)?;
self.save_meta(conn, item_id, "gid", gid)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct GroupMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl GroupMetaPlugin {
@@ -210,6 +284,7 @@ impl GroupMetaPlugin {
GroupMetaPlugin {
meta_name: "group".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -237,16 +312,38 @@ impl MetaPlugin for GroupMetaPlugin {
Some(groupname) => groupname.to_string_lossy().to_string(),
None => "unknown".to_string(),
};
self.save_meta(conn, item_id, group)?;
self.save_meta(conn, item_id, "group", group)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct ShellMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ShellMetaPlugin {
@@ -254,6 +351,7 @@ impl ShellMetaPlugin {
ShellMetaPlugin {
meta_name: "shell".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -281,16 +379,38 @@ impl MetaPlugin for ShellMetaPlugin {
Ok(shell) => shell,
Err(_) => "unknown".to_string(),
};
self.save_meta(conn, item_id, shell)?;
self.save_meta(conn, item_id, "shell", shell)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct ShellPidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ShellPidMetaPlugin {
@@ -298,6 +418,7 @@ impl ShellPidMetaPlugin {
ShellPidMetaPlugin {
meta_name: "shell_pid".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -325,16 +446,38 @@ impl MetaPlugin for ShellPidMetaPlugin {
Ok(ppid) => ppid,
Err(_) => process::id().to_string(),
};
self.save_meta(conn, item_id, pid)?;
self.save_meta(conn, item_id, "shell_pid", pid)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct KeepPidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl KeepPidMetaPlugin {
@@ -342,6 +485,7 @@ impl KeepPidMetaPlugin {
KeepPidMetaPlugin {
meta_name: "keep_pid".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -366,16 +510,38 @@ impl MetaPlugin for KeepPidMetaPlugin {
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
let pid = process::id().to_string();
self.save_meta(conn, item_id, pid)?;
self.save_meta(conn, item_id, "keep_pid", pid)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct HostnameMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl HostnameMetaPlugin {
@@ -383,6 +549,7 @@ impl HostnameMetaPlugin {
HostnameMetaPlugin {
meta_name: "hostname".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -410,16 +577,38 @@ impl MetaPlugin for HostnameMetaPlugin {
Ok(hostname) => hostname,
Err(_) => "unknown".to_string(),
};
self.save_meta(conn, item_id, hostname)?;
self.save_meta(conn, item_id, "hostname", hostname)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}
#[derive(Debug, Clone, Default)]
pub struct FullHostnameMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl FullHostnameMetaPlugin {
@@ -427,6 +616,7 @@ impl FullHostnameMetaPlugin {
FullHostnameMetaPlugin {
meta_name: "full_hostname".to_string(),
is_saved: false,
outputs: std::collections::HashMap::new(),
}
}
}
@@ -472,8 +662,29 @@ impl MetaPlugin for FullHostnameMetaPlugin {
}
}
};
self.save_meta(conn, item_id, hostname)?;
self.save_meta(conn, item_id, "full_hostname", hostname)?;
self.is_saved = true;
Ok(())
}
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
}
Ok(())
}
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}