mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
Allow hostnames to be specified by annotations for gateways with wildcard hosts
This commit is contained in:
parent
734cb7c4ae
commit
d69d191ea2
@ -272,11 +272,6 @@ func (sc *gatewaySource) endpointsFromGateway(hostnames []string, gateway networ
|
||||
|
||||
providerSpecific, setIdentifier := getProviderSpecificAnnotations(annotations)
|
||||
|
||||
// Skip endpoints if we do not want entries from annotations
|
||||
if !sc.ignoreHostnameAnnotation {
|
||||
hostnames = append(hostnames, getHostnamesFromAnnotations(annotations)...)
|
||||
}
|
||||
|
||||
for _, host := range hostnames {
|
||||
endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific, setIdentifier)...)
|
||||
}
|
||||
@ -305,6 +300,11 @@ func (sc *gatewaySource) hostNamesFromGateway(gateway networkingv1alpha3.Gateway
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !sc.ignoreHostnameAnnotation {
|
||||
hostnames = append(hostnames, getHostnamesFromAnnotations(gateway.Annotations)...)
|
||||
}
|
||||
|
||||
return hostnames, nil
|
||||
}
|
||||
|
||||
|
@ -1094,6 +1094,43 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
expected: []*endpoint.Endpoint{},
|
||||
},
|
||||
{
|
||||
title: "gateways with wildcard host and hostname annotation",
|
||||
targetNamespace: "",
|
||||
lbServices: []fakeIngressGatewayService{
|
||||
{
|
||||
ips: []string{"1.2.3.4"},
|
||||
},
|
||||
},
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "fake1.dns-through-hostname.com",
|
||||
},
|
||||
dnsnames: [][]string{{"*"}},
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "fake2.dns-through-hostname.com",
|
||||
},
|
||||
dnsnames: [][]string{{"some-namespace/*"}},
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
{
|
||||
DNSName: "fake1.dns-through-hostname.com",
|
||||
Targets: endpoint.Targets{"1.2.3.4"},
|
||||
},
|
||||
{
|
||||
DNSName: "fake2.dns-through-hostname.com",
|
||||
Targets: endpoint.Targets{"1.2.3.4"},
|
||||
},
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(ti.title, func(t *testing.T) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user