From d906a6ebb5d977f44340b157a520477849ced161 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 5 Apr 2023 16:02:32 +0200 Subject: refactoring --- src/dns_config.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dns_config.rs b/src/dns_config.rs index 9eb6075..8e82c32 100644 --- a/src/dns_config.rs +++ b/src/dns_config.rs @@ -138,26 +138,23 @@ impl DnsConfigFetcher { return Ok(None); } - let (record_type, targets) = match splits[0] { + let (record_type, target) = match splits[0] { "d53-a" => match self.get_node_ipv4(&node).await? { - Some(tgt) => (DnsRecordType::A, [tgt.to_string()].into_iter().collect()), + Some(tgt) => (DnsRecordType::A, tgt.to_string()), None => { warn!("Got d53-a tag `{}` but node {} does not appear to have a known public IPv4 address. Tag is ignored.", tag, node.node); return Ok(None); } }, "d53-aaaa" => match self.get_node_ipv6(&node).await? { - Some(tgt) => (DnsRecordType::AAAA, [tgt.to_string()].into_iter().collect()), + Some(tgt) => (DnsRecordType::AAAA, tgt.to_string()), None => { warn!("Got d53-aaaa tag `{}` but node {} does not appear to have a known public IPv6 address. Tag is ignored.", tag, node.node); return Ok(None); } }, "d53-cname" => match node.meta.get(CNAME_TARGET_METADATA_TAG) { - Some(tgt) => ( - DnsRecordType::CNAME, - [tgt.to_string()].into_iter().collect(), - ), + Some(tgt) => (DnsRecordType::CNAME, tgt.to_string()), None => { warn!("Got d53-cname tag `{}` but node {} does not have a {} metadata value. Tag is ignored.", tag, node.node, CNAME_TARGET_METADATA_TAG); return Ok(None); @@ -171,7 +168,9 @@ impl DnsConfigFetcher { dns_path: splits[1].to_string(), record_type, }, - DnsEntryValue { targets }, + DnsEntryValue { + targets: [target].into_iter().collect(), + }, ))) } -- cgit v1.2.3