mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
gateway-api: switch to v1beta1 apis where available
This commit is contained in:
parent
a7a56b9380
commit
b0dc1739aa
@ -5,9 +5,10 @@ It is meant to supplement the other provider-specific setup tutorials.
|
|||||||
|
|
||||||
## Supported API Versions
|
## Supported API Versions
|
||||||
|
|
||||||
The currently supported version of Gateway API is v1alpha2. However, the maintainers of ExternalDNS
|
As the Gateway API is still in an experimental phase, ExternalDNS makes no backwards
|
||||||
make no backwards compatibility guarantees with alpha versions of the API. Future releases may only
|
compatibilty guarantees regarding its support. However, it currently supports a mixture of
|
||||||
support beta or stable API versions.
|
v1alpha2 and v1beta1 APIs. Gateways and HTTPRoutes are supported using the v1beta1 API.
|
||||||
|
TLSRoutes, TCPRoutes, and UDPRoutes are supported using the v1alpha2 API.
|
||||||
|
|
||||||
## Hostnames
|
## Hostnames
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ import (
|
|||||||
kubeinformers "k8s.io/client-go/informers"
|
kubeinformers "k8s.io/client-go/informers"
|
||||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||||
cache "k8s.io/client-go/tools/cache"
|
cache "k8s.io/client-go/tools/cache"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
gateway "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
|
gateway "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
|
||||||
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
||||||
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
informers_v1b1 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1beta1"
|
||||||
|
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
)
|
)
|
||||||
@ -51,11 +51,11 @@ type gatewayRoute interface {
|
|||||||
// Metadata returns the route's metadata.
|
// Metadata returns the route's metadata.
|
||||||
Metadata() *metav1.ObjectMeta
|
Metadata() *metav1.ObjectMeta
|
||||||
// Hostnames returns the route's specified hostnames.
|
// Hostnames returns the route's specified hostnames.
|
||||||
Hostnames() []v1alpha2.Hostname
|
Hostnames() []v1beta1.Hostname
|
||||||
// Protocol returns the route's protocol type.
|
// Protocol returns the route's protocol type.
|
||||||
Protocol() v1alpha2.ProtocolType
|
Protocol() v1beta1.ProtocolType
|
||||||
// RouteStatus returns the route's common status.
|
// RouteStatus returns the route's common status.
|
||||||
RouteStatus() v1alpha2.RouteStatus
|
RouteStatus() v1beta1.RouteStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
type newGatewayRouteInformerFunc func(informers.SharedInformerFactory) gatewayRouteInformer
|
type newGatewayRouteInformerFunc func(informers.SharedInformerFactory) gatewayRouteInformer
|
||||||
@ -82,7 +82,7 @@ func newGatewayInformerFactory(client gateway.Interface, namespace string, label
|
|||||||
type gatewayRouteSource struct {
|
type gatewayRouteSource struct {
|
||||||
gwNamespace string
|
gwNamespace string
|
||||||
gwLabels labels.Selector
|
gwLabels labels.Selector
|
||||||
gwInformer informers_v1a2.GatewayInformer
|
gwInformer informers_v1b1.GatewayInformer
|
||||||
|
|
||||||
rtKind string
|
rtKind string
|
||||||
rtNamespace string
|
rtNamespace string
|
||||||
@ -123,8 +123,8 @@ func newGatewayRouteSource(clients ClientGenerator, config *Config, kind string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
informerFactory := newGatewayInformerFactory(client, config.GatewayNamespace, gwLabels)
|
informerFactory := newGatewayInformerFactory(client, config.GatewayNamespace, gwLabels)
|
||||||
gwInformer := informerFactory.Gateway().V1alpha2().Gateways() // TODO: Gateway informer should be shared across gateway sources.
|
gwInformer := informerFactory.Gateway().V1beta1().Gateways() // TODO: Gateway informer should be shared across gateway sources.
|
||||||
gwInformer.Informer() // Register with factory before starting.
|
gwInformer.Informer() // Register with factory before starting.
|
||||||
|
|
||||||
rtInformerFactory := informerFactory
|
rtInformerFactory := informerFactory
|
||||||
if config.Namespace != config.GatewayNamespace || !selectorsEqual(rtLabels, gwLabels) {
|
if config.Namespace != config.GatewayNamespace || !selectorsEqual(rtLabels, gwLabels) {
|
||||||
@ -257,15 +257,15 @@ type gatewayRouteResolver struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type gatewayListeners struct {
|
type gatewayListeners struct {
|
||||||
gateway *v1alpha2.Gateway
|
gateway *v1beta1.Gateway
|
||||||
listeners map[v1alpha2.SectionName][]v1alpha2.Listener
|
listeners map[v1beta1.SectionName][]v1beta1.Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGatewayRouteResolver(src *gatewayRouteSource, gateways []*v1alpha2.Gateway, namespaces []*corev1.Namespace) *gatewayRouteResolver {
|
func newGatewayRouteResolver(src *gatewayRouteSource, gateways []*v1beta1.Gateway, namespaces []*corev1.Namespace) *gatewayRouteResolver {
|
||||||
// Create Gateway Listener lookup table.
|
// Create Gateway Listener lookup table.
|
||||||
gws := make(map[types.NamespacedName]gatewayListeners, len(gateways))
|
gws := make(map[types.NamespacedName]gatewayListeners, len(gateways))
|
||||||
for _, gw := range gateways {
|
for _, gw := range gateways {
|
||||||
lss := make(map[v1alpha2.SectionName][]v1alpha2.Listener, len(gw.Spec.Listeners)+1)
|
lss := make(map[v1beta1.SectionName][]v1beta1.Listener, len(gw.Spec.Listeners)+1)
|
||||||
for i, lis := range gw.Spec.Listeners {
|
for i, lis := range gw.Spec.Listeners {
|
||||||
lss[lis.Name] = gw.Spec.Listeners[i : i+1]
|
lss[lis.Name] = gw.Spec.Listeners[i : i+1]
|
||||||
}
|
}
|
||||||
@ -397,23 +397,23 @@ func (c *gatewayRouteResolver) hosts(rt gatewayRoute) ([]string, error) {
|
|||||||
return hostnames, nil
|
return hostnames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *gatewayRouteResolver) routeIsAllowed(gw *v1alpha2.Gateway, lis *v1alpha2.Listener, rt gatewayRoute) bool {
|
func (c *gatewayRouteResolver) routeIsAllowed(gw *v1beta1.Gateway, lis *v1beta1.Listener, rt gatewayRoute) bool {
|
||||||
meta := rt.Metadata()
|
meta := rt.Metadata()
|
||||||
allow := lis.AllowedRoutes
|
allow := lis.AllowedRoutes
|
||||||
|
|
||||||
// Check the route's namespace.
|
// Check the route's namespace.
|
||||||
from := v1alpha2.NamespacesFromSame
|
from := v1beta1.NamespacesFromSame
|
||||||
if allow != nil && allow.Namespaces != nil && allow.Namespaces.From != nil {
|
if allow != nil && allow.Namespaces != nil && allow.Namespaces.From != nil {
|
||||||
from = *allow.Namespaces.From
|
from = *allow.Namespaces.From
|
||||||
}
|
}
|
||||||
switch from {
|
switch from {
|
||||||
case v1alpha2.NamespacesFromAll:
|
case v1beta1.NamespacesFromAll:
|
||||||
// OK
|
// OK
|
||||||
case v1alpha2.NamespacesFromSame:
|
case v1beta1.NamespacesFromSame:
|
||||||
if gw.Namespace != meta.Namespace {
|
if gw.Namespace != meta.Namespace {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case v1alpha2.NamespacesFromSelector:
|
case v1beta1.NamespacesFromSelector:
|
||||||
selector, err := metav1.LabelSelectorAsSelector(allow.Namespaces.Selector)
|
selector, err := metav1.LabelSelectorAsSelector(allow.Namespaces.Selector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("Gateway %s/%s section %q has invalid namespace selector: %v", gw.Namespace, gw.Name, lis.Name, err)
|
log.Debugf("Gateway %s/%s section %q has invalid namespace selector: %v", gw.Namespace, gw.Name, lis.Name, err)
|
||||||
@ -451,7 +451,7 @@ func (c *gatewayRouteResolver) routeIsAllowed(gw *v1alpha2.Gateway, lis *v1alpha
|
|||||||
|
|
||||||
func gwRouteIsAccepted(conds []metav1.Condition) bool {
|
func gwRouteIsAccepted(conds []metav1.Condition) bool {
|
||||||
for _, c := range conds {
|
for _, c := range conds {
|
||||||
if v1alpha2.RouteConditionType(c.Type) == v1alpha2.RouteConditionAccepted {
|
if v1beta1.RouteConditionType(c.Type) == v1beta1.RouteConditionAccepted {
|
||||||
return c.Status == metav1.ConditionTrue
|
return c.Status == metav1.ConditionTrue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,12 +478,12 @@ func uniqueTargets(targets endpoint.Targets) endpoint.Targets {
|
|||||||
|
|
||||||
// gwProtocolMatches returns whether a and b are the same protocol,
|
// gwProtocolMatches returns whether a and b are the same protocol,
|
||||||
// where HTTP and HTTPS are considered the same.
|
// where HTTP and HTTPS are considered the same.
|
||||||
func gwProtocolMatches(a, b v1alpha2.ProtocolType) bool {
|
func gwProtocolMatches(a, b v1beta1.ProtocolType) bool {
|
||||||
if a == v1alpha2.HTTPSProtocolType {
|
if a == v1beta1.HTTPSProtocolType {
|
||||||
a = v1alpha2.HTTPProtocolType
|
a = v1beta1.HTTPProtocolType
|
||||||
}
|
}
|
||||||
if b == v1alpha2.HTTPSProtocolType {
|
if b == v1beta1.HTTPSProtocolType {
|
||||||
b = v1alpha2.HTTPProtocolType
|
b = v1beta1.HTTPProtocolType
|
||||||
}
|
}
|
||||||
return a == b
|
return a == b
|
||||||
}
|
}
|
||||||
@ -531,7 +531,7 @@ func strVal(ptr *string, def string) string {
|
|||||||
return *ptr
|
return *ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
func sectionVal(ptr *v1alpha2.SectionName, def v1alpha2.SectionName) v1alpha2.SectionName {
|
func sectionVal(ptr *v1beta1.SectionName, def v1beta1.SectionName) v1beta1.SectionName {
|
||||||
if ptr == nil || *ptr == "" {
|
if ptr == nil || *ptr == "" {
|
||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
@ -19,28 +19,28 @@ package source
|
|||||||
import (
|
import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
||||||
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
informers_v1b1 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewGatewayHTTPRouteSource creates a new Gateway HTTPRoute source with the given config.
|
// NewGatewayHTTPRouteSource creates a new Gateway HTTPRoute source with the given config.
|
||||||
func NewGatewayHTTPRouteSource(clients ClientGenerator, config *Config) (Source, error) {
|
func NewGatewayHTTPRouteSource(clients ClientGenerator, config *Config) (Source, error) {
|
||||||
return newGatewayRouteSource(clients, config, "HTTPRoute", func(factory informers.SharedInformerFactory) gatewayRouteInformer {
|
return newGatewayRouteSource(clients, config, "HTTPRoute", func(factory informers.SharedInformerFactory) gatewayRouteInformer {
|
||||||
return &gatewayHTTPRouteInformer{factory.Gateway().V1alpha2().HTTPRoutes()}
|
return &gatewayHTTPRouteInformer{factory.Gateway().V1beta1().HTTPRoutes()}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type gatewayHTTPRoute struct{ route *v1alpha2.HTTPRoute }
|
type gatewayHTTPRoute struct{ route *v1beta1.HTTPRoute }
|
||||||
|
|
||||||
func (rt *gatewayHTTPRoute) Object() kubeObject { return rt.route }
|
func (rt *gatewayHTTPRoute) Object() kubeObject { return rt.route }
|
||||||
func (rt *gatewayHTTPRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
func (rt *gatewayHTTPRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
||||||
func (rt *gatewayHTTPRoute) Hostnames() []v1alpha2.Hostname { return rt.route.Spec.Hostnames }
|
func (rt *gatewayHTTPRoute) Hostnames() []v1beta1.Hostname { return rt.route.Spec.Hostnames }
|
||||||
func (rt *gatewayHTTPRoute) Protocol() v1alpha2.ProtocolType { return v1alpha2.HTTPProtocolType }
|
func (rt *gatewayHTTPRoute) Protocol() v1beta1.ProtocolType { return v1beta1.HTTPProtocolType }
|
||||||
func (rt *gatewayHTTPRoute) RouteStatus() v1alpha2.RouteStatus { return rt.route.Status.RouteStatus }
|
func (rt *gatewayHTTPRoute) RouteStatus() v1beta1.RouteStatus { return rt.route.Status.RouteStatus }
|
||||||
|
|
||||||
type gatewayHTTPRouteInformer struct {
|
type gatewayHTTPRouteInformer struct {
|
||||||
informers_v1a2.HTTPRouteInformer
|
informers_v1b1.HTTPRouteInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (inf gatewayHTTPRouteInformer) List(namespace string, selector labels.Selector) ([]gatewayRoute, error) {
|
func (inf gatewayHTTPRouteInformer) List(namespace string, selector labels.Selector) ([]gatewayRoute, error) {
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
kubefake "k8s.io/client-go/kubernetes/fake"
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,23 +38,23 @@ func mustGetLabelSelector(s string) labels.Selector {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatewayStatus(ips ...string) v1alpha2.GatewayStatus {
|
func gatewayStatus(ips ...string) v1beta1.GatewayStatus {
|
||||||
typ := v1alpha2.IPAddressType
|
typ := v1beta1.IPAddressType
|
||||||
addrs := make([]v1alpha2.GatewayAddress, len(ips))
|
addrs := make([]v1beta1.GatewayAddress, len(ips))
|
||||||
for i, ip := range ips {
|
for i, ip := range ips {
|
||||||
addrs[i] = v1alpha2.GatewayAddress{Type: &typ, Value: ip}
|
addrs[i] = v1beta1.GatewayAddress{Type: &typ, Value: ip}
|
||||||
}
|
}
|
||||||
return v1alpha2.GatewayStatus{Addresses: addrs}
|
return v1beta1.GatewayStatus{Addresses: addrs}
|
||||||
}
|
}
|
||||||
|
|
||||||
func routeStatus(refs ...v1alpha2.ParentReference) v1alpha2.RouteStatus {
|
func routeStatus(refs ...v1beta1.ParentReference) v1beta1.RouteStatus {
|
||||||
var v v1alpha2.RouteStatus
|
var v v1beta1.RouteStatus
|
||||||
for _, ref := range refs {
|
for _, ref := range refs {
|
||||||
v.Parents = append(v.Parents, v1alpha2.RouteParentStatus{
|
v.Parents = append(v.Parents, v1beta1.RouteParentStatus{
|
||||||
ParentRef: ref,
|
ParentRef: ref,
|
||||||
Conditions: []metav1.Condition{
|
Conditions: []metav1.Condition{
|
||||||
{
|
{
|
||||||
Type: string(v1alpha2.RouteConditionAccepted),
|
Type: string(v1beta1.RouteConditionAccepted),
|
||||||
Status: metav1.ConditionTrue,
|
Status: metav1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -63,28 +63,28 @@ func routeStatus(refs ...v1alpha2.ParentReference) v1alpha2.RouteStatus {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func httpRouteStatus(refs ...v1alpha2.ParentReference) v1alpha2.HTTPRouteStatus {
|
func httpRouteStatus(refs ...v1beta1.ParentReference) v1beta1.HTTPRouteStatus {
|
||||||
return v1alpha2.HTTPRouteStatus{RouteStatus: routeStatus(refs...)}
|
return v1beta1.HTTPRouteStatus{RouteStatus: routeStatus(refs...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
type parentRefOption func(*v1alpha2.ParentReference)
|
type parentRefOption func(*v1beta1.ParentReference)
|
||||||
|
|
||||||
func withSectionName(name v1alpha2.SectionName) parentRefOption {
|
func withSectionName(name v1beta1.SectionName) parentRefOption {
|
||||||
return func(ref *v1alpha2.ParentReference) { ref.SectionName = &name }
|
return func(ref *v1beta1.ParentReference) { ref.SectionName = &name }
|
||||||
}
|
}
|
||||||
|
|
||||||
func withPortNumber(port v1alpha2.PortNumber) parentRefOption {
|
func withPortNumber(port v1beta1.PortNumber) parentRefOption {
|
||||||
return func(ref *v1alpha2.ParentReference) { ref.Port = &port }
|
return func(ref *v1beta1.ParentReference) { ref.Port = &port }
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatewayParentRef(namespace, name string, options ...parentRefOption) v1alpha2.ParentReference {
|
func gatewayParentRef(namespace, name string, options ...parentRefOption) v1beta1.ParentReference {
|
||||||
group := v1alpha2.Group("gateway.networking.k8s.io")
|
group := v1beta1.Group("gateway.networking.k8s.io")
|
||||||
kind := v1alpha2.Kind("Gateway")
|
kind := v1beta1.Kind("Gateway")
|
||||||
ref := v1alpha2.ParentReference{
|
ref := v1beta1.ParentReference{
|
||||||
Group: &group,
|
Group: &group,
|
||||||
Kind: &kind,
|
Kind: &kind,
|
||||||
Name: v1alpha2.ObjectName(name),
|
Name: v1beta1.ObjectName(name),
|
||||||
Namespace: (*v1alpha2.Namespace)(&namespace),
|
Namespace: (*v1beta1.Namespace)(&namespace),
|
||||||
}
|
}
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
opt(&ref)
|
opt(&ref)
|
||||||
@ -108,11 +108,11 @@ func newTestEndpointWithTTL(dnsName, recordType string, ttl int64, targets ...st
|
|||||||
func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
fromAll := v1alpha2.NamespacesFromAll
|
fromAll := v1beta1.NamespacesFromAll
|
||||||
fromSame := v1alpha2.NamespacesFromSame
|
fromSame := v1beta1.NamespacesFromSame
|
||||||
fromSelector := v1alpha2.NamespacesFromSelector
|
fromSelector := v1beta1.NamespacesFromSelector
|
||||||
allowAllNamespaces := &v1alpha2.AllowedRoutes{
|
allowAllNamespaces := &v1beta1.AllowedRoutes{
|
||||||
Namespaces: &v1alpha2.RouteNamespaces{
|
Namespaces: &v1beta1.RouteNamespaces{
|
||||||
From: &fromAll,
|
From: &fromAll,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -129,14 +129,14 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
hostnames := func(names ...v1alpha2.Hostname) []v1alpha2.Hostname { return names }
|
hostnames := func(names ...v1beta1.Hostname) []v1beta1.Hostname { return names }
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
title string
|
title string
|
||||||
config Config
|
config Config
|
||||||
namespaces []*corev1.Namespace
|
namespaces []*corev1.Namespace
|
||||||
gateways []*v1alpha2.Gateway
|
gateways []*v1beta1.Gateway
|
||||||
routes []*v1alpha2.HTTPRoute
|
routes []*v1beta1.HTTPRoute
|
||||||
endpoints []*endpoint.Endpoint
|
endpoints []*endpoint.Endpoint
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -145,12 +145,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
GatewayNamespace: "gateway-namespace",
|
GatewayNamespace: "gateway-namespace",
|
||||||
},
|
},
|
||||||
namespaces: namespaces("gateway-namespace", "not-gateway-namespace", "route-namespace"),
|
namespaces: namespaces("gateway-namespace", "not-gateway-namespace", "route-namespace"),
|
||||||
gateways: []*v1alpha2.Gateway{
|
gateways: []*v1beta1.Gateway{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("gateway-namespace", "test"),
|
ObjectMeta: objectMeta("gateway-namespace", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
AllowedRoutes: allowAllNamespaces,
|
AllowedRoutes: allowAllNamespaces,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
@ -158,15 +158,15 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("not-gateway-namespace", "test"),
|
ObjectMeta: objectMeta("not-gateway-namespace", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("2.3.4.5"),
|
Status: gatewayStatus("2.3.4.5"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus( // The route is attached to both gateways.
|
||||||
@ -184,27 +184,27 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
Namespace: "route-namespace",
|
Namespace: "route-namespace",
|
||||||
},
|
},
|
||||||
namespaces: namespaces("gateway-namespace", "route-namespace", "not-route-namespace"),
|
namespaces: namespaces("gateway-namespace", "route-namespace", "not-route-namespace"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("gateway-namespace", "test"),
|
ObjectMeta: objectMeta("gateway-namespace", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
AllowedRoutes: allowAllNamespaces,
|
AllowedRoutes: allowAllNamespaces,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("route-namespace.example.internal"),
|
Hostnames: hostnames("route-namespace.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("gateway-namespace", "test")),
|
Status: httpRouteStatus(gatewayParentRef("gateway-namespace", "test")),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("not-route-namespace", "test"),
|
ObjectMeta: objectMeta("not-route-namespace", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("not-route-namespace.example.internal"),
|
Hostnames: hostnames("not-route-namespace.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("gateway-namespace", "test")),
|
Status: httpRouteStatus(gatewayParentRef("gateway-namespace", "test")),
|
||||||
@ -220,15 +220,15 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
GatewayLabelFilter: "foo=bar",
|
GatewayLabelFilter: "foo=bar",
|
||||||
},
|
},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{
|
gateways: []*v1beta1.Gateway{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "labels-match",
|
Name: "labels-match",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Labels: map[string]string{"foo": "bar"},
|
Labels: map[string]string{"foo": "bar"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
},
|
},
|
||||||
@ -238,15 +238,15 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Labels: map[string]string{"foo": "qux"},
|
Labels: map[string]string{"foo": "qux"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("2.3.4.5"),
|
Status: gatewayStatus("2.3.4.5"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus( // The route is attached to both gateways.
|
||||||
@ -264,21 +264,21 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
LabelFilter: mustGetLabelSelector("foo=bar"),
|
LabelFilter: mustGetLabelSelector("foo=bar"),
|
||||||
},
|
},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "labels-match",
|
Name: "labels-match",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Labels: map[string]string{"foo": "bar"},
|
Labels: map[string]string{"foo": "bar"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("labels-match.example.internal"),
|
Hostnames: hostnames("labels-match.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -289,7 +289,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Labels: map[string]string{"foo": "qux"},
|
Labels: map[string]string{"foo": "qux"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("labels-dont-match.example.internal"),
|
Hostnames: hostnames("labels-dont-match.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -305,21 +305,21 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
AnnotationFilter: "foo=bar",
|
AnnotationFilter: "foo=bar",
|
||||||
},
|
},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "annotations-match",
|
Name: "annotations-match",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Annotations: map[string]string{"foo": "bar"},
|
Annotations: map[string]string{"foo": "bar"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("annotations-match.example.internal"),
|
Hostnames: hostnames("annotations-match.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -330,7 +330,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Annotations: map[string]string{"foo": "qux"},
|
Annotations: map[string]string{"foo": "qux"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("annotations-dont-match.example.internal"),
|
Hostnames: hostnames("annotations-dont-match.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -344,14 +344,14 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "SkipControllerAnnotation",
|
title: "SkipControllerAnnotation",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "api",
|
Name: "api",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
@ -359,7 +359,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
controllerAnnotationKey: "something-else",
|
controllerAnnotationKey: "something-else",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("api.example.internal"),
|
Hostnames: hostnames("api.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -370,25 +370,25 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "MultipleGateways",
|
title: "MultipleGateways",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{
|
gateways: []*v1beta1.Gateway{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "one"),
|
ObjectMeta: objectMeta("default", "one"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "two"),
|
ObjectMeta: objectMeta("default", "two"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("2.3.4.5"),
|
Status: gatewayStatus("2.3.4.5"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
@ -404,27 +404,27 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "MultipleListeners",
|
title: "MultipleListeners",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "one"),
|
ObjectMeta: objectMeta("default", "one"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{
|
Listeners: []v1beta1.Listener{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("foo.example.internal"),
|
Hostname: hostnamePtr("foo.example.internal"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("bar.example.internal"),
|
Hostname: hostnamePtr("bar.example.internal"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("*.example.internal"),
|
Hostnames: hostnames("*.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
@ -440,27 +440,27 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "SectionNameMatch",
|
title: "SectionNameMatch",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{
|
Listeners: []v1beta1.Listener{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("foo.example.internal"),
|
Hostname: hostnamePtr("foo.example.internal"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("bar.example.internal"),
|
Hostname: hostnamePtr("bar.example.internal"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("*.example.internal"),
|
Hostnames: hostnames("*.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
@ -476,25 +476,25 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "PortNumberMatch",
|
title: "PortNumberMatch",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{
|
Listeners: []v1beta1.Listener{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("foo.example.internal"),
|
Hostname: hostnamePtr("foo.example.internal"),
|
||||||
Port: 80,
|
Port: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("bar.example.internal"),
|
Hostname: hostnamePtr("bar.example.internal"),
|
||||||
Port: 80,
|
Port: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "qux",
|
Name: "qux",
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("qux.example.internal"),
|
Hostname: hostnamePtr("qux.example.internal"),
|
||||||
Port: 8080,
|
Port: 8080,
|
||||||
},
|
},
|
||||||
@ -502,9 +502,9 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("*.example.internal"),
|
Hostnames: hostnames("*.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
@ -520,20 +520,20 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "WildcardInGateway",
|
title: "WildcardInGateway",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("*.example.internal"),
|
Hostname: hostnamePtr("*.example.internal"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: []v1alpha2.Hostname{
|
Hostnames: []v1beta1.Hostname{
|
||||||
"foo.example.internal",
|
"foo.example.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -547,20 +547,20 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "WildcardInRoute",
|
title: "WildcardInRoute",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("foo.example.internal"),
|
Hostname: hostnamePtr("foo.example.internal"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: []v1alpha2.Hostname{
|
Hostnames: []v1beta1.Hostname{
|
||||||
"*.example.internal",
|
"*.example.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -574,20 +574,20 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "WildcardInRouteAndGateway",
|
title: "WildcardInRouteAndGateway",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("*.example.internal"),
|
Hostname: hostnamePtr("*.example.internal"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: []v1alpha2.Hostname{
|
Hostnames: []v1beta1.Hostname{
|
||||||
"*.example.internal",
|
"*.example.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -601,19 +601,19 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "NoRouteHostname",
|
title: "NoRouteHostname",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
Hostname: hostnamePtr("foo.example.internal"),
|
Hostname: hostnamePtr("foo.example.internal"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -627,9 +627,9 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: nil,
|
gateways: nil,
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("example.internal"),
|
Hostnames: hostnames("example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(),
|
Status: httpRouteStatus(),
|
||||||
@ -640,16 +640,16 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "NoHostnames",
|
title: "NoHostnames",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -660,14 +660,14 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "HostnameAnnotation",
|
title: "HostnameAnnotation",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "without-hostame",
|
Name: "without-hostame",
|
||||||
@ -676,7 +676,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
hostnameAnnotationKey: "annotation.without-hostname.internal",
|
hostnameAnnotationKey: "annotation.without-hostname.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -689,7 +689,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
hostnameAnnotationKey: "annotation.with-hostname.internal",
|
hostnameAnnotationKey: "annotation.with-hostname.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("with-hostname.internal"),
|
Hostnames: hostnames("with-hostname.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -707,14 +707,14 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
IgnoreHostnameAnnotation: true,
|
IgnoreHostnameAnnotation: true,
|
||||||
},
|
},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "with-hostame",
|
Name: "with-hostame",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
@ -722,7 +722,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
hostnameAnnotationKey: "annotation.with-hostname.internal",
|
hostnameAnnotationKey: "annotation.with-hostname.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("with-hostname.internal"),
|
Hostnames: hostnames("with-hostname.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -737,24 +737,24 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
FQDNTemplate: "{{.Name}}.zero.internal, {{.Name}}.one.internal. , {{.Name}}.two.internal ",
|
FQDNTemplate: "{{.Name}}.zero.internal, {{.Name}}.one.internal. , {{.Name}}.two.internal ",
|
||||||
},
|
},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "fqdn-without-hostnames"),
|
ObjectMeta: objectMeta("default", "fqdn-without-hostnames"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -774,16 +774,16 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
CombineFQDNAndAnnotation: true,
|
CombineFQDNAndAnnotation: true,
|
||||||
},
|
},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -797,21 +797,21 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "TTL",
|
title: "TTL",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "valid-ttl",
|
Name: "valid-ttl",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Annotations: map[string]string{ttlAnnotationKey: "15s"},
|
Annotations: map[string]string{ttlAnnotationKey: "15s"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("valid-ttl.internal"),
|
Hostnames: hostnames("valid-ttl.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -822,7 +822,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Annotations: map[string]string{ttlAnnotationKey: "abc"},
|
Annotations: map[string]string{ttlAnnotationKey: "abc"},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("invalid-ttl.internal"),
|
Hostnames: hostnames("invalid-ttl.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -837,14 +837,14 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "ProviderAnnotations",
|
title: "ProviderAnnotations",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{Protocol: v1alpha2.HTTPProtocolType}},
|
Listeners: []v1beta1.Listener{{Protocol: v1beta1.HTTPProtocolType}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "provider-annotations",
|
Name: "provider-annotations",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
@ -853,7 +853,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
aliasAnnotationKey: "true",
|
aliasAnnotationKey: "true",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("provider-annotations.com"),
|
Hostnames: hostnames("provider-annotations.com"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -868,31 +868,31 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "DifferentHostnameDifferentGateway",
|
title: "DifferentHostnameDifferentGateway",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("default"),
|
namespaces: namespaces("default"),
|
||||||
gateways: []*v1alpha2.Gateway{
|
gateways: []*v1beta1.Gateway{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "one"),
|
ObjectMeta: objectMeta("default", "one"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Hostname: hostnamePtr("*.one.internal"),
|
Hostname: hostnamePtr("*.one.internal"),
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "two"),
|
ObjectMeta: objectMeta("default", "two"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Hostname: hostnamePtr("*.two.internal"),
|
Hostname: hostnamePtr("*.two.internal"),
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus("2.3.4.5"),
|
Status: gatewayStatus("2.3.4.5"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.one.internal", "test.two.internal"),
|
Hostnames: hostnames("test.one.internal", "test.two.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
@ -909,13 +909,13 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "AllowedRoutesSameNamespace",
|
title: "AllowedRoutesSameNamespace",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: namespaces("same-namespace", "other-namespace"),
|
namespaces: namespaces("same-namespace", "other-namespace"),
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("same-namespace", "test"),
|
ObjectMeta: objectMeta("same-namespace", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
AllowedRoutes: &v1alpha2.AllowedRoutes{
|
AllowedRoutes: &v1beta1.AllowedRoutes{
|
||||||
Namespaces: &v1alpha2.RouteNamespaces{
|
Namespaces: &v1beta1.RouteNamespaces{
|
||||||
From: &fromSame,
|
From: &fromSame,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -923,17 +923,17 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("same-namespace", "test"),
|
ObjectMeta: objectMeta("same-namespace", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("same-namespace.example.internal"),
|
Hostnames: hostnames("same-namespace.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("same-namespace", "test")),
|
Status: httpRouteStatus(gatewayParentRef("same-namespace", "test")),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("other-namespace", "test"),
|
ObjectMeta: objectMeta("other-namespace", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("other-namespace.example.internal"),
|
Hostnames: hostnames("other-namespace.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("same-namespace", "test")),
|
Status: httpRouteStatus(gatewayParentRef("same-namespace", "test")),
|
||||||
@ -965,13 +965,13 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
AllowedRoutes: &v1alpha2.AllowedRoutes{
|
AllowedRoutes: &v1beta1.AllowedRoutes{
|
||||||
Namespaces: &v1alpha2.RouteNamespaces{
|
Namespaces: &v1beta1.RouteNamespaces{
|
||||||
From: &fromSelector,
|
From: &fromSelector,
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
MatchLabels: map[string]string{"team": "foo"},
|
MatchLabels: map[string]string{"team": "foo"},
|
||||||
@ -982,17 +982,17 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{
|
routes: []*v1beta1.HTTPRoute{
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("foo", "test"),
|
ObjectMeta: objectMeta("foo", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("foo.example.internal"),
|
Hostnames: hostnames("foo.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("bar", "test"),
|
ObjectMeta: objectMeta("bar", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("bar.example.internal"),
|
Hostnames: hostnames("bar.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -1006,13 +1006,13 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
title: "MissingNamespace",
|
title: "MissingNamespace",
|
||||||
config: Config{},
|
config: Config{},
|
||||||
namespaces: nil,
|
namespaces: nil,
|
||||||
gateways: []*v1alpha2.Gateway{{
|
gateways: []*v1beta1.Gateway{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.HTTPProtocolType,
|
Protocol: v1beta1.HTTPProtocolType,
|
||||||
AllowedRoutes: &v1alpha2.AllowedRoutes{
|
AllowedRoutes: &v1beta1.AllowedRoutes{
|
||||||
Namespaces: &v1alpha2.RouteNamespaces{
|
Namespaces: &v1beta1.RouteNamespaces{
|
||||||
// Namespace selector triggers namespace lookup.
|
// Namespace selector triggers namespace lookup.
|
||||||
From: &fromSelector,
|
From: &fromSelector,
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
@ -1024,9 +1024,9 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Status: gatewayStatus("1.2.3.4"),
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
}},
|
}},
|
||||||
routes: []*v1alpha2.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1alpha2.HTTPRouteSpec{
|
Spec: v1beta1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("example.internal"),
|
Hostnames: hostnames("example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
Status: httpRouteStatus(gatewayParentRef("default", "test")),
|
||||||
@ -1042,12 +1042,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
gwClient := gatewayfake.NewSimpleClientset()
|
gwClient := gatewayfake.NewSimpleClientset()
|
||||||
for _, gw := range tt.gateways {
|
for _, gw := range tt.gateways {
|
||||||
_, err := gwClient.GatewayV1alpha2().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
_, err := gwClient.GatewayV1beta1().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
||||||
require.NoError(t, err, "failed to create Gateway")
|
require.NoError(t, err, "failed to create Gateway")
|
||||||
|
|
||||||
}
|
}
|
||||||
for _, rt := range tt.routes {
|
for _, rt := range tt.routes {
|
||||||
_, err := gwClient.GatewayV1alpha2().HTTPRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
_, err := gwClient.GatewayV1beta1().HTTPRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
||||||
require.NoError(t, err, "failed to create HTTPRoute")
|
require.NoError(t, err, "failed to create HTTPRoute")
|
||||||
}
|
}
|
||||||
kubeClient := kubefake.NewSimpleClientset()
|
kubeClient := kubefake.NewSimpleClientset()
|
||||||
@ -1070,4 +1070,4 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostnamePtr(val v1alpha2.Hostname) *v1alpha2.Hostname { return &val }
|
func hostnamePtr(val v1beta1.Hostname) *v1beta1.Hostname { return &val }
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
||||||
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
||||||
)
|
)
|
||||||
@ -33,11 +34,13 @@ func NewGatewayTCPRouteSource(clients ClientGenerator, config *Config) (Source,
|
|||||||
|
|
||||||
type gatewayTCPRoute struct{ route *v1alpha2.TCPRoute }
|
type gatewayTCPRoute struct{ route *v1alpha2.TCPRoute }
|
||||||
|
|
||||||
func (rt *gatewayTCPRoute) Object() kubeObject { return rt.route }
|
func (rt *gatewayTCPRoute) Object() kubeObject { return rt.route }
|
||||||
func (rt *gatewayTCPRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
func (rt *gatewayTCPRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
||||||
func (rt *gatewayTCPRoute) Hostnames() []v1alpha2.Hostname { return nil }
|
func (rt *gatewayTCPRoute) Hostnames() []v1beta1.Hostname { return nil }
|
||||||
func (rt *gatewayTCPRoute) Protocol() v1alpha2.ProtocolType { return v1alpha2.TCPProtocolType }
|
func (rt *gatewayTCPRoute) Protocol() v1beta1.ProtocolType { return v1beta1.TCPProtocolType }
|
||||||
func (rt *gatewayTCPRoute) RouteStatus() v1alpha2.RouteStatus { return rt.route.Status.RouteStatus }
|
func (rt *gatewayTCPRoute) RouteStatus() v1beta1.RouteStatus {
|
||||||
|
return v1b1RouteStatus(rt.route.Status.RouteStatus)
|
||||||
|
}
|
||||||
|
|
||||||
type gatewayTCPRouteInformer struct {
|
type gatewayTCPRouteInformer struct {
|
||||||
informers_v1a2.TCPRouteInformer
|
informers_v1a2.TCPRouteInformer
|
||||||
@ -54,3 +57,50 @@ func (inf gatewayTCPRouteInformer) List(namespace string, selector labels.Select
|
|||||||
}
|
}
|
||||||
return routes, nil
|
return routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func v1b1Hostnames(hostnames []v1alpha2.Hostname) []v1beta1.Hostname {
|
||||||
|
if len(hostnames) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
list := make([]v1beta1.Hostname, len(hostnames))
|
||||||
|
for i, s := range hostnames {
|
||||||
|
list[i] = v1beta1.Hostname(s)
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
func v1b1RouteStatus(s v1alpha2.RouteStatus) v1beta1.RouteStatus {
|
||||||
|
return v1beta1.RouteStatus{
|
||||||
|
Parents: v1b1RouteParentStatuses(s.Parents),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func v1b1RouteParentStatuses(statuses []v1alpha2.RouteParentStatus) []v1beta1.RouteParentStatus {
|
||||||
|
if len(statuses) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
list := make([]v1beta1.RouteParentStatus, len(statuses))
|
||||||
|
for i, s := range statuses {
|
||||||
|
list[i] = v1b1RouteParentStatus(s)
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
func v1b1RouteParentStatus(s v1alpha2.RouteParentStatus) v1beta1.RouteParentStatus {
|
||||||
|
return v1beta1.RouteParentStatus{
|
||||||
|
ParentRef: v1b1ParentReference(s.ParentRef),
|
||||||
|
ControllerName: v1beta1.GatewayController(s.ControllerName),
|
||||||
|
Conditions: s.Conditions,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func v1b1ParentReference(s v1alpha2.ParentReference) v1beta1.ParentReference {
|
||||||
|
return v1beta1.ParentReference{
|
||||||
|
Group: (*v1beta1.Group)(s.Group),
|
||||||
|
Kind: (*v1beta1.Kind)(s.Kind),
|
||||||
|
Namespace: (*v1beta1.Namespace)(s.Namespace),
|
||||||
|
Name: v1beta1.ObjectName(s.Name),
|
||||||
|
SectionName: (*v1beta1.SectionName)(s.SectionName),
|
||||||
|
Port: (*v1beta1.PortNumber)(s.Port),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
kubefake "k8s.io/client-go/kubernetes/fake"
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,19 +49,19 @@ func TestGatewayTCPRouteSourceEndpoints(t *testing.T) {
|
|||||||
require.NoError(t, err, "failed to create Namespace")
|
require.NoError(t, err, "failed to create Namespace")
|
||||||
|
|
||||||
ips := []string{"10.64.0.1", "10.64.0.2"}
|
ips := []string{"10.64.0.1", "10.64.0.2"}
|
||||||
gw := &v1alpha2.Gateway{
|
gw := &v1beta1.Gateway{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "internal",
|
Name: "internal",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.TCPProtocolType,
|
Protocol: v1beta1.TCPProtocolType,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus(ips...),
|
Status: gatewayStatus(ips...),
|
||||||
}
|
}
|
||||||
_, err = gwClient.GatewayV1alpha2().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
_, err = gwClient.GatewayV1beta1().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
||||||
require.NoError(t, err, "failed to create Gateway")
|
require.NoError(t, err, "failed to create Gateway")
|
||||||
|
|
||||||
rt := &v1alpha2.TCPRoute{
|
rt := &v1alpha2.TCPRoute{
|
||||||
@ -73,7 +74,7 @@ func TestGatewayTCPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1alpha2.TCPRouteSpec{},
|
Spec: v1alpha2.TCPRouteSpec{},
|
||||||
Status: v1alpha2.TCPRouteStatus{
|
Status: v1alpha2.TCPRouteStatus{
|
||||||
RouteStatus: routeStatus(gatewayParentRef("default", "internal")),
|
RouteStatus: v1a2RouteStatus(v1a2ParentRef("default", "internal")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = gwClient.GatewayV1alpha2().TCPRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
_, err = gwClient.GatewayV1alpha2().TCPRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
||||||
@ -92,3 +93,31 @@ func TestGatewayTCPRouteSourceEndpoints(t *testing.T) {
|
|||||||
newTestEndpoint("api-template.foobar.internal", "A", ips...),
|
newTestEndpoint("api-template.foobar.internal", "A", ips...),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func v1a2ParentRef(namespace, name string) v1alpha2.ParentReference {
|
||||||
|
group := v1alpha2.Group("gateway.networking.k8s.io")
|
||||||
|
kind := v1alpha2.Kind("Gateway")
|
||||||
|
ref := v1alpha2.ParentReference{
|
||||||
|
Group: &group,
|
||||||
|
Kind: &kind,
|
||||||
|
Name: v1alpha2.ObjectName(name),
|
||||||
|
Namespace: (*v1alpha2.Namespace)(&namespace),
|
||||||
|
}
|
||||||
|
return ref
|
||||||
|
}
|
||||||
|
|
||||||
|
func v1a2RouteStatus(refs ...v1alpha2.ParentReference) v1alpha2.RouteStatus {
|
||||||
|
var v v1alpha2.RouteStatus
|
||||||
|
for _, ref := range refs {
|
||||||
|
v.Parents = append(v.Parents, v1alpha2.RouteParentStatus{
|
||||||
|
ParentRef: ref,
|
||||||
|
Conditions: []metav1.Condition{
|
||||||
|
{
|
||||||
|
Type: string(v1alpha2.RouteConditionAccepted),
|
||||||
|
Status: metav1.ConditionTrue,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
||||||
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
||||||
)
|
)
|
||||||
@ -33,11 +34,15 @@ func NewGatewayTLSRouteSource(clients ClientGenerator, config *Config) (Source,
|
|||||||
|
|
||||||
type gatewayTLSRoute struct{ route *v1alpha2.TLSRoute }
|
type gatewayTLSRoute struct{ route *v1alpha2.TLSRoute }
|
||||||
|
|
||||||
func (rt *gatewayTLSRoute) Object() kubeObject { return rt.route }
|
func (rt *gatewayTLSRoute) Object() kubeObject { return rt.route }
|
||||||
func (rt *gatewayTLSRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
func (rt *gatewayTLSRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
||||||
func (rt *gatewayTLSRoute) Hostnames() []v1alpha2.Hostname { return rt.route.Spec.Hostnames }
|
func (rt *gatewayTLSRoute) Hostnames() []v1beta1.Hostname {
|
||||||
func (rt *gatewayTLSRoute) Protocol() v1alpha2.ProtocolType { return v1alpha2.TLSProtocolType }
|
return v1b1Hostnames(rt.route.Spec.Hostnames)
|
||||||
func (rt *gatewayTLSRoute) RouteStatus() v1alpha2.RouteStatus { return rt.route.Status.RouteStatus }
|
}
|
||||||
|
func (rt *gatewayTLSRoute) Protocol() v1beta1.ProtocolType { return v1beta1.TLSProtocolType }
|
||||||
|
func (rt *gatewayTLSRoute) RouteStatus() v1beta1.RouteStatus {
|
||||||
|
return v1b1RouteStatus(rt.route.Status.RouteStatus)
|
||||||
|
}
|
||||||
|
|
||||||
type gatewayTLSRouteInformer struct {
|
type gatewayTLSRouteInformer struct {
|
||||||
informers_v1a2.TLSRouteInformer
|
informers_v1a2.TLSRouteInformer
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
kubefake "k8s.io/client-go/kubernetes/fake"
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,19 +49,19 @@ func TestGatewayTLSRouteSourceEndpoints(t *testing.T) {
|
|||||||
require.NoError(t, err, "failed to create Namespace")
|
require.NoError(t, err, "failed to create Namespace")
|
||||||
|
|
||||||
ips := []string{"10.64.0.1", "10.64.0.2"}
|
ips := []string{"10.64.0.1", "10.64.0.2"}
|
||||||
gw := &v1alpha2.Gateway{
|
gw := &v1beta1.Gateway{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "internal",
|
Name: "internal",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.TLSProtocolType,
|
Protocol: v1beta1.TLSProtocolType,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus(ips...),
|
Status: gatewayStatus(ips...),
|
||||||
}
|
}
|
||||||
_, err = gwClient.GatewayV1alpha2().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
_, err = gwClient.GatewayV1beta1().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
||||||
require.NoError(t, err, "failed to create Gateway")
|
require.NoError(t, err, "failed to create Gateway")
|
||||||
|
|
||||||
rt := &v1alpha2.TLSRoute{
|
rt := &v1alpha2.TLSRoute{
|
||||||
@ -75,7 +76,7 @@ func TestGatewayTLSRouteSourceEndpoints(t *testing.T) {
|
|||||||
Hostnames: []v1alpha2.Hostname{"api-hostnames.foobar.internal"},
|
Hostnames: []v1alpha2.Hostname{"api-hostnames.foobar.internal"},
|
||||||
},
|
},
|
||||||
Status: v1alpha2.TLSRouteStatus{
|
Status: v1alpha2.TLSRouteStatus{
|
||||||
RouteStatus: routeStatus(gatewayParentRef("default", "internal")),
|
RouteStatus: v1a2RouteStatus(v1a2ParentRef("default", "internal")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = gwClient.GatewayV1alpha2().TLSRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
_, err = gwClient.GatewayV1alpha2().TLSRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
|
||||||
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
|
||||||
)
|
)
|
||||||
@ -33,11 +34,13 @@ func NewGatewayUDPRouteSource(clients ClientGenerator, config *Config) (Source,
|
|||||||
|
|
||||||
type gatewayUDPRoute struct{ route *v1alpha2.UDPRoute }
|
type gatewayUDPRoute struct{ route *v1alpha2.UDPRoute }
|
||||||
|
|
||||||
func (rt *gatewayUDPRoute) Object() kubeObject { return rt.route }
|
func (rt *gatewayUDPRoute) Object() kubeObject { return rt.route }
|
||||||
func (rt *gatewayUDPRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
func (rt *gatewayUDPRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
|
||||||
func (rt *gatewayUDPRoute) Hostnames() []v1alpha2.Hostname { return nil }
|
func (rt *gatewayUDPRoute) Hostnames() []v1beta1.Hostname { return nil }
|
||||||
func (rt *gatewayUDPRoute) Protocol() v1alpha2.ProtocolType { return v1alpha2.UDPProtocolType }
|
func (rt *gatewayUDPRoute) Protocol() v1beta1.ProtocolType { return v1beta1.UDPProtocolType }
|
||||||
func (rt *gatewayUDPRoute) RouteStatus() v1alpha2.RouteStatus { return rt.route.Status.RouteStatus }
|
func (rt *gatewayUDPRoute) RouteStatus() v1beta1.RouteStatus {
|
||||||
|
return v1b1RouteStatus(rt.route.Status.RouteStatus)
|
||||||
|
}
|
||||||
|
|
||||||
type gatewayUDPRouteInformer struct {
|
type gatewayUDPRouteInformer struct {
|
||||||
informers_v1a2.UDPRouteInformer
|
informers_v1a2.UDPRouteInformer
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
kubefake "k8s.io/client-go/kubernetes/fake"
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
"sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
|
"sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,19 +49,19 @@ func TestGatewayUDPRouteSourceEndpoints(t *testing.T) {
|
|||||||
require.NoError(t, err, "failed to create Namespace")
|
require.NoError(t, err, "failed to create Namespace")
|
||||||
|
|
||||||
ips := []string{"10.64.0.1", "10.64.0.2"}
|
ips := []string{"10.64.0.1", "10.64.0.2"}
|
||||||
gw := &v1alpha2.Gateway{
|
gw := &v1beta1.Gateway{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "internal",
|
Name: "internal",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.GatewaySpec{
|
Spec: v1beta1.GatewaySpec{
|
||||||
Listeners: []v1alpha2.Listener{{
|
Listeners: []v1beta1.Listener{{
|
||||||
Protocol: v1alpha2.UDPProtocolType,
|
Protocol: v1beta1.UDPProtocolType,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
Status: gatewayStatus(ips...),
|
Status: gatewayStatus(ips...),
|
||||||
}
|
}
|
||||||
_, err = gwClient.GatewayV1alpha2().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
_, err = gwClient.GatewayV1beta1().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
|
||||||
require.NoError(t, err, "failed to create Gateway")
|
require.NoError(t, err, "failed to create Gateway")
|
||||||
|
|
||||||
rt := &v1alpha2.UDPRoute{
|
rt := &v1alpha2.UDPRoute{
|
||||||
@ -73,7 +74,7 @@ func TestGatewayUDPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1alpha2.UDPRouteSpec{},
|
Spec: v1alpha2.UDPRouteSpec{},
|
||||||
Status: v1alpha2.UDPRouteStatus{
|
Status: v1alpha2.UDPRouteStatus{
|
||||||
RouteStatus: routeStatus(gatewayParentRef("default", "internal")),
|
RouteStatus: v1a2RouteStatus(v1a2ParentRef("default", "internal")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = gwClient.GatewayV1alpha2().UDPRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
_, err = gwClient.GatewayV1alpha2().UDPRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
|
||||||
|
Loading…
Reference in New Issue
Block a user