Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ type EndpointKey struct {
RecordType string
SetIdentifier string
RecordTTL TTL
Target string
}

type ObjectRef = events.ObjectReference
Expand Down
7 changes: 1 addition & 6 deletions source/ambassador_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"sort"
"strings"

ambassador "github.com/datawire/ambassador/pkg/api/getambassador.io/v2"
Expand Down Expand Up @@ -181,11 +180,7 @@ func (sc *ambassadorHostSource) Endpoints(ctx context.Context) ([]*endpoint.Endp
endpoints = append(endpoints, hostEndpoints...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// endpointsFromHost extracts the endpoints from a Host object
Expand Down
2 changes: 1 addition & 1 deletion source/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (cs *connectorSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, e

log.Debugf("Received endpoints: %#v", endpoints)

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (cs *connectorSource) AddEventHandler(_ context.Context, _ func()) {}
7 changes: 1 addition & 6 deletions source/contour_httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"sort"
"text/template"

projectcontour "github.com/projectcontour/contour/apis/projectcontour/v1"
Expand Down Expand Up @@ -167,11 +166,7 @@ func (sc *httpProxySource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, e
endpoints = append(endpoints, hpEndpoints...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (sc *httpProxySource) endpointsFromTemplate(httpProxy *projectcontour.HTTPProxy) ([]*endpoint.Endpoint, error) {
Expand Down
2 changes: 1 addition & 1 deletion source/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
}
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (cs *crdSource) watch(ctx context.Context, opts *metav1.ListOptions) (watch.Interface, error) {
Expand Down
2 changes: 1 addition & 1 deletion source/f5_transportserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (ts *f5TransportServerSource) Endpoints(_ context.Context) ([]*endpoint.End
return nil, err
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (ts *f5TransportServerSource) AddEventHandler(_ context.Context, handler func()) {
Expand Down
8 changes: 1 addition & 7 deletions source/f5_virtualserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"sort"
"strings"

f5 "github.com/F5Networks/k8s-bigip-ctlr/v2/config/apis/cis/v1"
Expand Down Expand Up @@ -131,12 +130,7 @@ func (vs *f5VirtualServerSource) Endpoints(_ context.Context) ([]*endpoint.Endpo
return nil, err
}

// Sort endpoints
for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (vs *f5VirtualServerSource) AddEventHandler(_ context.Context, handler func()) {
Expand Down
9 changes: 4 additions & 5 deletions source/f5_virtualserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const defaultF5VirtualServerNamespace = "virtualserver"

func TestF5VirtualServerEndpoints(t *testing.T) {
t.Parallel()

tests := []struct {
name string
annotationFilter string
Expand Down Expand Up @@ -349,7 +348,7 @@ func TestF5VirtualServerEndpoints(t *testing.T) {
},
expected: []*endpoint.Endpoint{
{
DNSName: "www.example.com",
DNSName: "alias1.example.com",
Targets: []string{"192.168.1.100"},
RecordType: endpoint.RecordTypeA,
RecordTTL: 0,
Expand All @@ -358,7 +357,7 @@ func TestF5VirtualServerEndpoints(t *testing.T) {
},
},
{
DNSName: "alias1.example.com",
DNSName: "alias2.example.com",
Targets: []string{"192.168.1.100"},
RecordType: endpoint.RecordTypeA,
RecordTTL: 0,
Expand All @@ -367,7 +366,7 @@ func TestF5VirtualServerEndpoints(t *testing.T) {
},
},
{
DNSName: "alias2.example.com",
DNSName: "www.example.com",
Targets: []string{"192.168.1.100"},
RecordType: endpoint.RecordTypeA,
RecordTTL: 0,
Expand Down Expand Up @@ -600,7 +599,7 @@ func TestF5VirtualServerEndpoints(t *testing.T) {
endpoints, err := source.Endpoints(context.Background())
require.NoError(t, err)
assert.Len(t, endpoints, len(tc.expected))
assert.Equal(t, tc.expected, endpoints)
validateEndpoints(t, endpoints, tc.expected)
})
}
}
2 changes: 1 addition & 1 deletion source/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (sc *fakeSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, error)
endpoints[i] = sc.generateEndpoint()
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (sc *fakeSource) generateEndpoint() *endpoint.Endpoint {
Expand Down
2 changes: 1 addition & 1 deletion source/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (src *gatewayRouteSource) Endpoints(_ context.Context) ([]*endpoint.Endpoin

endpoints = append(endpoints, routeEndpoints...)
}
return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func namespacedName(namespace, name string) types.NamespacedName {
Expand Down
2 changes: 1 addition & 1 deletion source/gloo_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (gs *glooSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, error)
endpoints = append(endpoints, proxyEndpoints...)
}
}
return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (gs *glooSource) generateEndpointsFromProxy(proxy *proxy, targets endpoint.Targets) ([]*endpoint.Endpoint, error) {
Expand Down
7 changes: 1 addition & 6 deletions source/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"sort"
"strings"
"text/template"

Expand Down Expand Up @@ -179,11 +178,7 @@ func (sc *ingressSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, err
endpoints = append(endpoints, ingEndpoints...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (sc *ingressSource) endpointsFromTemplate(ing *networkv1.Ingress) ([]*endpoint.Endpoint, error) {
Expand Down
1 change: 0 additions & 1 deletion source/ingress_fqdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) {
fqdnTemplate: `{{ range .Status.LoadBalancer.Ingress }}{{ if contains .Hostname "nip.io" }}example.org{{end}}{{end}}`,
expected: []*endpoint.Endpoint{
{DNSName: "example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"10.200.130.84.nip.io"}},
{DNSName: "example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"10.200.130.84.nip.io"}},
},
},
{
Expand Down
8 changes: 1 addition & 7 deletions source/istio_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package source
import (
"context"
"fmt"
"sort"
"strings"
"text/template"

Expand Down Expand Up @@ -196,12 +195,7 @@ func (sc *gatewaySource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, e
endpoints = append(endpoints, gwEndpoints...)
}

// TODO: sort on endpoint creation
for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// AddEventHandler adds an event handler that should be triggered if the watched Istio Gateway changes.
Expand Down
1 change: 0 additions & 1 deletion source/istio_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,6 @@ func TestSingleGatewayMultipleServicesPointingToSameLoadBalancer(t *testing.T) {

validateEndpoints(t, got, []*endpoint.Endpoint{
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "34.66.66.77").WithLabel(endpoint.ResourceLabelKey, "gateway/argocd/argocd"),
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "34.66.66.77").WithLabel(endpoint.ResourceLabelKey, "gateway/argocd/argocd"),
})
}

Expand Down
8 changes: 1 addition & 7 deletions source/istio_virtualservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"context"
"fmt"
"slices"
"sort"
"strings"
"text/template"

Expand Down Expand Up @@ -187,12 +186,7 @@ func (sc *virtualServiceSource) Endpoints(ctx context.Context) ([]*endpoint.Endp
endpoints = append(endpoints, gwEndpoints...)
}

// TODO: sort on endpoint creation
for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// AddEventHandler adds an event handler that should be triggered if the watched Istio VirtualService changes.
Expand Down
7 changes: 1 addition & 6 deletions source/kong_tcpingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"sort"

log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -160,11 +159,7 @@ func (sc *kongTCPIngressSource) Endpoints(_ context.Context) ([]*endpoint.Endpoi
endpoints = append(endpoints, ingressEndpoints...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// endpointsFromTCPIngress extracts the endpoints from a TCPIngress object
Expand Down
3 changes: 1 addition & 2 deletions source/kong_tcpingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ func TestKongTCPIngressEndpoints(t *testing.T) {

endpoints, err := source.Endpoints(context.Background())
assert.NoError(t, err)
assert.Len(t, endpoints, len(ti.expected))
assert.Equal(t, ti.expected, endpoints)
validateEndpoints(t, endpoints, ti.expected)
})
}
}
2 changes: 1 addition & 1 deletion source/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (ns *nodeSource) endpointsForDNSNames(node *v1.Node, dnsNames []string) ([]
}
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// nodeAddress returns the node's externalIP and if that's not found, the node's internalIP
Expand Down
7 changes: 1 addition & 6 deletions source/openshift_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package source
import (
"context"
"fmt"
"sort"
"text/template"
"time"

Expand Down Expand Up @@ -159,11 +158,7 @@ func (ors *ocpRouteSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, e
endpoints = append(endpoints, orEndpoints...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (ors *ocpRouteSource) endpointsFromTemplate(ocpRoute *routev1.Route) ([]*endpoint.Endpoint, error) {
Expand Down
1 change: 0 additions & 1 deletion source/openshift_route_fqdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func TestOpenShiftFqdnTemplatingExamples(t *testing.T) {
title: "get canonical hostnames for admitted routes",
fqdnTemplate: "{{ $name := .Name }}{{ range $ingress := .Status.Ingress }}{{ range $ingress.Conditions }}{{ if and (eq .Type \"Admitted\") (eq .Status \"True\") }}{{ $ingress.Host }},{{ end }}{{ end }}{{ end }}",
expected: []*endpoint.Endpoint{
{DNSName: "cluster.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"router-dmz.apps.dmz.example.com"}},
{DNSName: "cluster.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"router-dmz.apps.dmz.example.com"}},
{DNSName: "apps.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"router-dmz.apps.dmz.example.com"}},
},
Expand Down
2 changes: 1 addition & 1 deletion source/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (sc *serviceSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, err
})
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// extractHeadlessEndpoints extracts endpoints from a headless service using the "Endpoints" Kubernetes API resource
Expand Down
7 changes: 1 addition & 6 deletions source/skipper_routegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"net/http"
"net/url"
"os"
"sort"
"strings"
"sync"
"text/template"
Expand Down Expand Up @@ -288,11 +287,7 @@ func (sc *routeGroupSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint,
endpoints = append(endpoints, eps...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

func (sc *routeGroupSource) endpointsFromTemplate(rg *routeGroup) ([]*endpoint.Endpoint, error) {
Expand Down
7 changes: 1 addition & 6 deletions source/traefik_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"regexp"
"sort"
"strings"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -209,11 +208,7 @@ func (ts *traefikSource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, err
endpoints = append(endpoints, oldIngressRouteUdpEndpoints...)
}

for _, ep := range endpoints {
sort.Sort(ep.Targets)
}

return endpoints, nil
return MergeEndpoints(endpoints), nil
}

// ingressRouteEndpoints extracts endpoints from all IngressRoute objects
Expand Down
Loading
Loading