Make the IngressRoute kind optional
This commit is contained in:
parent
e8ff825ed2
commit
97caf758ef
7 changed files with 35 additions and 10 deletions
|
@ -57,6 +57,7 @@ spec:
|
|||
description: |-
|
||||
Kind defines the kind of the route.
|
||||
Rule is the only supported kind.
|
||||
If not defined, defaults to Rule.
|
||||
enum:
|
||||
- Rule
|
||||
type: string
|
||||
|
@ -280,7 +281,6 @@ spec:
|
|||
More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#rulesyntax
|
||||
type: string
|
||||
required:
|
||||
- kind
|
||||
- match
|
||||
type: object
|
||||
type: array
|
||||
|
|
|
@ -57,6 +57,7 @@ spec:
|
|||
description: |-
|
||||
Kind defines the kind of the route.
|
||||
Rule is the only supported kind.
|
||||
If not defined, defaults to Rule.
|
||||
enum:
|
||||
- Rule
|
||||
type: string
|
||||
|
@ -280,7 +281,6 @@ spec:
|
|||
More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#rulesyntax
|
||||
type: string
|
||||
required:
|
||||
- kind
|
||||
- match
|
||||
type: object
|
||||
type: array
|
||||
|
|
|
@ -57,6 +57,7 @@ spec:
|
|||
description: |-
|
||||
Kind defines the kind of the route.
|
||||
Rule is the only supported kind.
|
||||
If not defined, defaults to Rule.
|
||||
enum:
|
||||
- Rule
|
||||
type: string
|
||||
|
@ -280,7 +281,6 @@ spec:
|
|||
More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#rulesyntax
|
||||
type: string
|
||||
required:
|
||||
- kind
|
||||
- match
|
||||
type: object
|
||||
type: array
|
||||
|
|
|
@ -60,7 +60,7 @@ func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Cli
|
|||
}
|
||||
|
||||
for _, route := range ingressRoute.Spec.Routes {
|
||||
if route.Kind != "Rule" {
|
||||
if len(route.Kind) > 0 && route.Kind != "Rule" {
|
||||
logger.Error().Msgf("Unsupported match kind: %s. Only \"Rule\" is supported for now.", route.Kind)
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -3114,8 +3114,8 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
desc: "Route with kind not of a rule type (empty kind) is ignored",
|
||||
paths: []string{"services.yml", "with_wrong_rule_kind.yml"},
|
||||
desc: "Route with empty kind is allowed",
|
||||
paths: []string{"services.yml", "with_empty_rule_kind.yml"},
|
||||
expected: &dynamic.Configuration{
|
||||
UDP: &dynamic.UDPConfiguration{
|
||||
Routers: map[string]*dynamic.UDPRouter{},
|
||||
|
@ -3129,9 +3129,33 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
||||
},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"default-test-route-02719a68b11e915a4b23": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "default-test-route-02719a68b11e915a4b23",
|
||||
Rule: "/prefix",
|
||||
Priority: 12,
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Services: map[string]*dynamic.Service{
|
||||
"default-test-route-02719a68b11e915a4b23": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:80",
|
||||
},
|
||||
{
|
||||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: Bool(true),
|
||||
ResponseForwarding: &dynamic.ResponseForwarding{
|
||||
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ServersTransports: map[string]*dynamic.ServersTransport{},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -28,8 +28,9 @@ type Route struct {
|
|||
Match string `json:"match"`
|
||||
// Kind defines the kind of the route.
|
||||
// Rule is the only supported kind.
|
||||
// If not defined, defaults to Rule.
|
||||
// +kubebuilder:validation:Enum=Rule
|
||||
Kind string `json:"kind"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// Priority defines the router's priority.
|
||||
// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#priority
|
||||
Priority int `json:"priority,omitempty"`
|
||||
|
|
Loading…
Reference in a new issue