Merge current v2.4 into v2.5
This commit is contained in:
commit
187ec26d8e
6 changed files with 52 additions and 4 deletions
|
@ -73,6 +73,10 @@ blocks:
|
||||||
run:
|
run:
|
||||||
when: "tag =~ '.*'"
|
when: "tag =~ '.*'"
|
||||||
task:
|
task:
|
||||||
|
agent:
|
||||||
|
machine:
|
||||||
|
type: e1-standard-8
|
||||||
|
os_image: ubuntu1804
|
||||||
secrets:
|
secrets:
|
||||||
- name: traefik
|
- name: traefik
|
||||||
env_vars:
|
env_vars:
|
||||||
|
|
|
@ -24,7 +24,7 @@ func DecodeToNode(pairs []*store.KVPair, rootName string, filters ...string) (*p
|
||||||
return nil, fmt.Errorf("invalid label root %s", rootName)
|
return nil, fmt.Errorf("invalid label root %s", rootName)
|
||||||
}
|
}
|
||||||
|
|
||||||
split := strings.Split(pair.Key[len(rootName)+1:], "/")
|
split := strings.FieldsFunc(pair.Key[len(rootName)+1:], func(c rune) bool { return c == '/' })
|
||||||
|
|
||||||
parts := []string{rootName}
|
parts := []string{rootName}
|
||||||
for _, fragment := range split {
|
for _, fragment := range split {
|
||||||
|
|
|
@ -28,6 +28,7 @@ func TestDecode(t *testing.T) {
|
||||||
"traefik/fieldf/Test2": "B",
|
"traefik/fieldf/Test2": "B",
|
||||||
"traefik/fieldg/0/name": "A",
|
"traefik/fieldg/0/name": "A",
|
||||||
"traefik/fieldg/1/name": "B",
|
"traefik/fieldg/1/name": "B",
|
||||||
|
"traefik/fieldh/": "foo",
|
||||||
},
|
},
|
||||||
expected: &sample{
|
expected: &sample{
|
||||||
FieldA: "bar",
|
FieldA: "bar",
|
||||||
|
@ -45,6 +46,7 @@ func TestDecode(t *testing.T) {
|
||||||
{Name: "A"},
|
{Name: "A"},
|
||||||
{Name: "B"},
|
{Name: "B"},
|
||||||
},
|
},
|
||||||
|
FieldH: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -61,6 +63,7 @@ func TestDecode(t *testing.T) {
|
||||||
"foo/bar/traefik/fieldf/Test2": "B",
|
"foo/bar/traefik/fieldf/Test2": "B",
|
||||||
"foo/bar/traefik/fieldg/0/name": "A",
|
"foo/bar/traefik/fieldg/0/name": "A",
|
||||||
"foo/bar/traefik/fieldg/1/name": "B",
|
"foo/bar/traefik/fieldg/1/name": "B",
|
||||||
|
"foo/bar/traefik/fieldh/": "foo",
|
||||||
},
|
},
|
||||||
expected: &sample{
|
expected: &sample{
|
||||||
FieldA: "bar",
|
FieldA: "bar",
|
||||||
|
@ -78,6 +81,7 @@ func TestDecode(t *testing.T) {
|
||||||
{Name: "A"},
|
{Name: "A"},
|
||||||
{Name: "B"},
|
{Name: "B"},
|
||||||
},
|
},
|
||||||
|
FieldH: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -107,6 +111,7 @@ type sample struct {
|
||||||
} `label:"allowEmpty"`
|
} `label:"allowEmpty"`
|
||||||
FieldF map[string]string
|
FieldF map[string]string
|
||||||
FieldG []sub
|
FieldG []sub
|
||||||
|
FieldH string
|
||||||
}
|
}
|
||||||
|
|
||||||
type sub struct {
|
type sub struct {
|
||||||
|
|
|
@ -28,6 +28,15 @@ spec:
|
||||||
port: 80
|
port: 80
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: test-errorpage
|
- name: test-errorpage
|
||||||
|
- match: Host(`foo.com`) && PathPrefix(`/bur`)
|
||||||
|
kind: Rule
|
||||||
|
priority: 12
|
||||||
|
services:
|
||||||
|
- name: whoami
|
||||||
|
namespace: default
|
||||||
|
port: 80
|
||||||
|
middlewares:
|
||||||
|
- name: cross-ns-stripprefix@kubernetescrd
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: traefik.containo.us/v1alpha1
|
apiVersion: traefik.containo.us/v1alpha1
|
||||||
|
|
|
@ -147,13 +147,23 @@ func (p *Provider) makeMiddlewareKeys(ctx context.Context, ingRouteNamespace str
|
||||||
var mds []string
|
var mds []string
|
||||||
|
|
||||||
for _, mi := range middlewares {
|
for _, mi := range middlewares {
|
||||||
if strings.Contains(mi.Name, providerNamespaceSeparator) {
|
name := mi.Name
|
||||||
|
|
||||||
|
if !p.AllowCrossNamespace && strings.HasSuffix(mi.Name, providerNamespaceSeparator+providerName) {
|
||||||
|
// Since we are not able to know if another namespace is in the name (namespace-name@kubernetescrd),
|
||||||
|
// if the provider namespace kubernetescrd is used,
|
||||||
|
// we don't allow this format to avoid cross namespace references.
|
||||||
|
return nil, fmt.Errorf("invalid reference to middleware %s: with crossnamespace disallowed, the namespace field needs to be explicitly specified", mi.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(name, providerNamespaceSeparator) {
|
||||||
if len(mi.Namespace) > 0 {
|
if len(mi.Namespace) > 0 {
|
||||||
log.FromContext(ctx).
|
log.FromContext(ctx).
|
||||||
WithField(log.MiddlewareName, mi.Name).
|
WithField(log.MiddlewareName, mi.Name).
|
||||||
Warnf("namespace %q is ignored in cross-provider context", mi.Namespace)
|
Warnf("namespace %q is ignored in cross-provider context", mi.Namespace)
|
||||||
}
|
}
|
||||||
mds = append(mds, mi.Name)
|
|
||||||
|
mds = append(mds, name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +176,7 @@ func (p *Provider) makeMiddlewareKeys(ctx context.Context, ingRouteNamespace str
|
||||||
ns = mi.Namespace
|
ns = mi.Namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
mds = append(mds, makeID(ns, mi.Name))
|
mds = append(mds, makeID(ns, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
return mds, nil
|
return mds, nil
|
||||||
|
|
|
@ -4313,6 +4313,13 @@ func TestCrossNamespace(t *testing.T) {
|
||||||
Priority: 12,
|
Priority: 12,
|
||||||
Middlewares: []string{"default-test-errorpage"},
|
Middlewares: []string{"default-test-errorpage"},
|
||||||
},
|
},
|
||||||
|
"default-test-crossnamespace-route-a1963878aac7331b7950": {
|
||||||
|
EntryPoints: []string{"foo"},
|
||||||
|
Service: "default-test-crossnamespace-route-a1963878aac7331b7950",
|
||||||
|
Rule: "Host(`foo.com`) && PathPrefix(`/bur`)",
|
||||||
|
Priority: 12,
|
||||||
|
Middlewares: []string{"cross-ns-stripprefix@kubernetescrd"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Middlewares: map[string]*dynamic.Middleware{
|
Middlewares: map[string]*dynamic.Middleware{
|
||||||
"cross-ns-stripprefix": {
|
"cross-ns-stripprefix": {
|
||||||
|
@ -4369,6 +4376,19 @@ func TestCrossNamespace(t *testing.T) {
|
||||||
PassHostHeader: Bool(true),
|
PassHostHeader: Bool(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"default-test-crossnamespace-route-a1963878aac7331b7950": {
|
||||||
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||||
|
Servers: []dynamic.Server{
|
||||||
|
{
|
||||||
|
URL: "http://10.10.0.1:80",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
URL: "http://10.10.0.2:80",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PassHostHeader: Bool(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ServersTransports: map[string]*dynamic.ServersTransport{},
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue