mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
move ingress annotation and parseIngress to gateway source
This commit is contained in:
parent
08b592d2fd
commit
f9600b7b35
@ -38,6 +38,10 @@ import (
|
||||
"sigs.k8s.io/external-dns/endpoint"
|
||||
)
|
||||
|
||||
// IstioGatewayIngressSource is the annotation used to determine if the gateway is implemented by an Ingress object
|
||||
// instead of a standard LoadBalancer service type
|
||||
const IstioGatewayIngressSource = "external-dns.alpha.kubernetes.io/ingress"
|
||||
|
||||
// gatewaySource is an implementation of Source for Istio Gateway objects.
|
||||
// The gateway implementation uses the spec.servers.hosts values for the hostnames.
|
||||
// Use targetAnnotationKey to explicitly set Endpoint.
|
||||
@ -232,6 +236,19 @@ func (sc *gatewaySource) setResourceLabel(gateway *networkingv1alpha3.Gateway, e
|
||||
}
|
||||
}
|
||||
|
||||
func parseIngress(ingress string) (namespace, name string, err error) {
|
||||
parts := strings.Split(ingress, "/")
|
||||
if len(parts) == 2 {
|
||||
namespace, name = parts[0], parts[1]
|
||||
} else if len(parts) == 1 {
|
||||
name = parts[0]
|
||||
} else {
|
||||
err = fmt.Errorf("invalid ingress name (name or namespace/name) found '%v'", ingress)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (sc *gatewaySource) targetsFromIngress(ctx context.Context, ingressStr string, gateway *networkingv1alpha3.Gateway) (targets endpoint.Targets, err error) {
|
||||
namespace, name, err := parseIngress(ingressStr)
|
||||
if err != nil {
|
||||
|
@ -42,10 +42,6 @@ import (
|
||||
// IstioMeshGateway is the built in gateway for all sidecars
|
||||
const IstioMeshGateway = "mesh"
|
||||
|
||||
// IstioGatewayIngressSource is the annotation used to determine if the gateway is implemented by an Ingress object
|
||||
// instead of a standard LoadBalancer service type
|
||||
const IstioGatewayIngressSource = "external-dns.alpha.kubernetes.io/ingress"
|
||||
|
||||
// virtualServiceSource is an implementation of Source for Istio VirtualService objects.
|
||||
// The implementation uses the spec.hosts values for the hostnames.
|
||||
// Use targetAnnotationKey to explicitly set Endpoint.
|
||||
@ -435,19 +431,6 @@ func parseGateway(gateway string) (namespace, name string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func parseIngress(ingress string) (namespace, name string, err error) {
|
||||
parts := strings.Split(ingress, "/")
|
||||
if len(parts) == 2 {
|
||||
namespace, name = parts[0], parts[1]
|
||||
} else if len(parts) == 1 {
|
||||
name = parts[0]
|
||||
} else {
|
||||
err = fmt.Errorf("invalid ingress name (name or namespace/name) found '%v'", ingress)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (sc *virtualServiceSource) targetsFromIngress(ctx context.Context, ingressStr string, gateway *networkingv1alpha3.Gateway) (targets endpoint.Targets, err error) {
|
||||
namespace, name, err := parseIngress(ingressStr)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user