diff --git a/source/istio_gateway.go b/source/istio_gateway.go index 13861d72d..6ca6c9994 100644 --- a/source/istio_gateway.go +++ b/source/istio_gateway.go @@ -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 { diff --git a/source/istio_virtualservice.go b/source/istio_virtualservice.go index 1143bf0fa..3e7f79a74 100644 --- a/source/istio_virtualservice.go +++ b/source/istio_virtualservice.go @@ -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 {