Skip to content

Commit

Permalink
fix(proxmoxve): remove redundant afterburn prefix in attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
arcln committed Jan 9, 2024
1 parent 6d90e90 commit e84362d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
14 changes: 4 additions & 10 deletions src/providers/proxmoxve/cloudconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,22 @@ impl MetadataProvider for ProxmoxVECloudConfig {
let mut out = HashMap::new();

out.insert(
"AFTERBURN_PROXMOXVE_HOSTNAME".to_owned(),
"PROXMOXVE_HOSTNAME".to_owned(),
self.hostname()?.unwrap_or_default(),
);

out.insert(
"AFTERBURN_PROXMOXVE_INSTANCE_ID".to_owned(),
"PROXMOXVE_INSTANCE_ID".to_owned(),
self.meta_data.instance_id.clone(),
);

if let Some(first_interface) = self.networks()?.first() {
first_interface.ip_addresses.iter().for_each(|ip| match ip {
IpNetwork::V4(network) => {
out.insert(
"AFTERBURN_PROXMOXVE_IPV4".to_owned(),
network.ip().to_string(),
);
out.insert("PROXMOXVE_IPV4".to_owned(), network.ip().to_string());
}
IpNetwork::V6(network) => {
out.insert(
"AFTERBURN_PROXMOXVE_IPV6".to_owned(),
network.ip().to_string(),
);
out.insert("PROXMOXVE_IPV6".to_owned(), network.ip().to_string());
}
});
}
Expand Down
14 changes: 4 additions & 10 deletions src/providers/proxmoxve/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@ fn test_attributes() {
.expect("cannot parse config");
let attributes = config.attributes().expect("cannot get hostname");

assert_eq!(
attributes["AFTERBURN_PROXMOXVE_HOSTNAME"],
"dummy".to_string()
);
assert_eq!(attributes["PROXMOXVE_HOSTNAME"], "dummy".to_string());

assert_eq!(
attributes["AFTERBURN_PROXMOXVE_INSTANCE_ID"],
attributes["PROXMOXVE_INSTANCE_ID"],
"15a9919cb91024fbd1d70fa07f0efa749cbba03b".to_string()
);

assert_eq!(
attributes["AFTERBURN_PROXMOXVE_IPV4"],
"192.168.1.1".to_string()
);
assert_eq!(attributes["PROXMOXVE_IPV4"], "192.168.1.1".to_string());

assert_eq!(
attributes["AFTERBURN_PROXMOXVE_IPV6"],
attributes["PROXMOXVE_IPV6"],
"2001:db8:85a3::8a2e:370:0".to_string()
);
}
Expand Down

0 comments on commit e84362d

Please sign in to comment.