From 069f639f441e7553f733d9796cbdb3c4bb26d6c0 Mon Sep 17 00:00:00 2001 From: Arthur Chaloin Date: Thu, 7 Dec 2023 10:10:43 +0000 Subject: [PATCH] fix(proxmoxve): don't crash when there is no network interface --- src/providers/proxmoxve/cloudconfig.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/providers/proxmoxve/cloudconfig.rs b/src/providers/proxmoxve/cloudconfig.rs index 0e874a88..cf4a3fc1 100644 --- a/src/providers/proxmoxve/cloudconfig.rs +++ b/src/providers/proxmoxve/cloudconfig.rs @@ -157,12 +157,14 @@ impl MetadataProvider for ProxmoxVECloudConfig { .map(|entry| entry.to_interface()) .collect::, _>>()?; - if let Some(nameserver) = nameservers.first() { - interfaces[0].nameservers = nameserver - .address - .iter() - .map(|ip| IpAddr::from_str(ip)) - .collect::, AddrParseError>>()?; + if let Some(iface) = interfaces.first_mut() { + if let Some(nameserver) = nameservers.first() { + iface.nameservers = nameserver + .address + .iter() + .map(|ip| IpAddr::from_str(ip)) + .collect::, AddrParseError>>()?; + } } Ok(interfaces)