From b1a75fe810cdb405fa5858918e16ba55f34d734e Mon Sep 17 00:00:00 2001 From: Arthur Chaloin Date: Thu, 13 Jun 2024 14:08:54 +0000 Subject: [PATCH] proxmoxve: don't generate hostname attirbute if no hostname --- src/providers/proxmoxve/cloudconfig.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/providers/proxmoxve/cloudconfig.rs b/src/providers/proxmoxve/cloudconfig.rs index d05bc3ce..6be26763 100644 --- a/src/providers/proxmoxve/cloudconfig.rs +++ b/src/providers/proxmoxve/cloudconfig.rs @@ -109,16 +109,15 @@ impl MetadataProvider for ProxmoxVECloudConfig { fn attributes(&self) -> Result> { let mut out = HashMap::new(); - out.insert( - "PROXMOXVE_HOSTNAME".to_owned(), - self.hostname()?.unwrap_or_default(), - ); - out.insert( "PROXMOXVE_INSTANCE_ID".to_owned(), self.meta_data.instance_id.clone(), ); + if let Some(hostname) = self.hostname()? { + out.insert("PROXMOXVE_HOSTNAME".to_owned(), hostname); + } + if let Some(first_interface) = self.networks()?.first() { first_interface.ip_addresses.iter().for_each(|ip| match ip { IpNetwork::V4(network) => {