Skip to content

Commit 4c93c63

Browse files
committed
add support of comma-separated list of domains in 'dns.pfsense.org/hostname' annotaion
1 parent d4ec389 commit 4c93c63

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/KubernetesPfSenseController/Plugin/DNSServices.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ public function buildResourceHosts(&$resourceHosts, $service)
9393
if (!$this->shouldCreateHost($service)) {
9494
return;
9595
}
96-
$hostName = KubernetesUtils::getServiceHostname($service);
96+
$hostNames = KubernetesUtils::getServiceHostname($service);
9797
$ip = KubernetesUtils::getServiceIp($service);
98-
$resourceHosts[$hostName] = [
99-
'ip' => $ip,
100-
'resource' => $service,
101-
];
98+
foreach ($hostNames as $hostName) {
99+
$resourceHosts[$hostName] = [
100+
'ip' => $ip,
101+
'resource' => $service,
102+
];
103+
}
102104
}
103105

104106
/**
@@ -126,11 +128,13 @@ private function shouldCreateHost($service)
126128
}
127129

128130
$pluginConfig = $this->getConfig();
129-
$hostName = KubernetesUtils::getServiceHostname($service);
131+
$hostNames = KubernetesUtils::getServiceHostname($service);
130132
if (!empty($pluginConfig['allowedHostRegex'])) {
131-
$allowed = @preg_match($pluginConfig['allowedHostRegex'], $hostName);
132-
if ($allowed !== 1) {
133-
return false;
133+
foreach ($hostNames as $hostName) {
134+
$allowed = @preg_match($pluginConfig['allowedHostRegex'], $hostName);
135+
if ($allowed !== 1) {
136+
return false;
137+
}
134138
}
135139
}
136140

src/KubernetesPfSenseController/Plugin/KubernetesUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static function getServiceHostname($service)
228228
{
229229
foreach ($service['metadata']['annotations'] as $key => $value) {
230230
if ($key == self::SERVICE_HOSTNAME_ANNOTATION) {
231-
return $value;
231+
return explode(",", $value);
232232
}
233233
}
234234
}

0 commit comments

Comments
 (0)