Handle middlewares in filters extension ref in gateway api provider
Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
39fe3869b6
commit
618fb5f232
8 changed files with 858 additions and 100 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -26,6 +27,7 @@ import (
|
|||
"github.com/traefik/traefik/v3/pkg/logs"
|
||||
"github.com/traefik/traefik/v3/pkg/provider"
|
||||
traefikv1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
|
||||
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/gateway"
|
||||
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/k8s"
|
||||
"github.com/traefik/traefik/v3/pkg/safe"
|
||||
"github.com/traefik/traefik/v3/pkg/tls"
|
||||
|
@ -712,6 +714,24 @@ func (p *Provider) createErrorPageMiddleware(client Client, namespace string, er
|
|||
return errorPageMiddleware, balancerServerHTTP, nil
|
||||
}
|
||||
|
||||
func (p *Provider) FillExtensionBuilderRegistry(registry gateway.ExtensionBuilderRegistry) {
|
||||
registry.RegisterFilterFuncs(traefikv1alpha1.GroupName, "Middleware", func(name, namespace string) (string, *dynamic.Middleware, error) {
|
||||
if len(p.Namespaces) > 0 && !slices.Contains(p.Namespaces, namespace) {
|
||||
return "", nil, fmt.Errorf("namespace %q is not allowed", namespace)
|
||||
}
|
||||
|
||||
return makeID(namespace, name) + providerNamespaceSeparator + providerName, nil, nil
|
||||
})
|
||||
|
||||
registry.RegisterBackendFuncs(traefikv1alpha1.GroupName, "TraefikService", func(name, namespace string) (string, *dynamic.Service, error) {
|
||||
if len(p.Namespaces) > 0 && !slices.Contains(p.Namespaces, namespace) {
|
||||
return "", nil, fmt.Errorf("namespace %q is not allowed", namespace)
|
||||
}
|
||||
|
||||
return makeID(namespace, name) + providerNamespaceSeparator + providerName, nil, nil
|
||||
})
|
||||
}
|
||||
|
||||
func createForwardAuthMiddleware(k8sClient Client, namespace string, auth *traefikv1alpha1.ForwardAuth) (*dynamic.ForwardAuth, error) {
|
||||
if auth == nil {
|
||||
return nil, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue