Change the provider separator from . to @

This commit is contained in:
Ludovic Fernandez 2019-06-20 00:40:05 +02:00 committed by Traefiker Bot
parent 4012599264
commit e9792b446f
34 changed files with 465 additions and 465 deletions

View file

@ -77,7 +77,7 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
desc: "Should prefix the middlewareName with the provider in the context",
buildChain: []string{"middleware-1"},
configuration: map[string]*config.Middleware{
"provider-1.middleware-1": {
"provider-1@middleware-1": {
Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"provider-1.middleware-1": "value-middleware-1"},
},
@ -88,9 +88,9 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
},
{
desc: "Should not prefix a qualified middlewareName with the provider in the context",
buildChain: []string{"provider-1.middleware-1"},
buildChain: []string{"provider-1@middleware-1"},
configuration: map[string]*config.Middleware{
"provider-1.middleware-1": {
"provider-1@middleware-1": {
Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"provider-1.middleware-1": "value-middleware-1"},
},
@ -101,14 +101,14 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
},
{
desc: "Should be context aware if a chain references another middleware",
buildChain: []string{"provider-1.middleware-chain-1"},
buildChain: []string{"provider-1@middleware-chain-1"},
configuration: map[string]*config.Middleware{
"provider-1.middleware-1": {
"provider-1@middleware-1": {
Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
},
},
"provider-1.middleware-chain-1": {
"provider-1@middleware-chain-1": {
Chain: &config.Chain{
Middlewares: []string{"middleware-1"},
},
@ -118,31 +118,31 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
},
{
desc: "Should handle nested chains with different context",
buildChain: []string{"provider-1.middleware-chain-1", "middleware-chain-1"},
buildChain: []string{"provider-1@middleware-chain-1", "middleware-chain-1"},
configuration: map[string]*config.Middleware{
"provider-1.middleware-1": {
"provider-1@middleware-1": {
Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
},
},
"provider-1.middleware-2": {
"provider-1@middleware-2": {
Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"middleware-2": "value-middleware-2"},
},
},
"provider-1.middleware-chain-1": {
"provider-1@middleware-chain-1": {
Chain: &config.Chain{
Middlewares: []string{"middleware-1"},
},
},
"provider-1.middleware-chain-2": {
"provider-1@middleware-chain-2": {
Chain: &config.Chain{
Middlewares: []string{"middleware-2"},
},
},
"provider-2.middleware-chain-1": {
"provider-2@middleware-chain-1": {
Chain: &config.Chain{
Middlewares: []string{"provider-1.middleware-2", "provider-1.middleware-chain-2"},
Middlewares: []string{"provider-1@middleware-2", "provider-1@middleware-chain-2"},
},
},
},
@ -176,28 +176,28 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
},
{
desc: "Detects recursion in Middleware chain",
buildChain: []string{"provider.m1"},
buildChain: []string{"provider@m1"},
configuration: map[string]*config.Middleware{
"provider2.ok": {
"provider2@ok": {
Retry: &config.Retry{},
},
"provider.m1": {
"provider@m1": {
Chain: &config.Chain{
Middlewares: []string{"provider2.m2"},
Middlewares: []string{"provider2@m2"},
},
},
"provider2.m2": {
"provider2@m2": {
Chain: &config.Chain{
Middlewares: []string{"ok", "provider.m3"},
Middlewares: []string{"ok", "provider@m3"},
},
},
"provider.m3": {
"provider@m3": {
Chain: &config.Chain{
Middlewares: []string{"m1"},
},
},
},
expectedError: errors.New("could not instantiate middleware provider.m1: recursion detected in provider.m1->provider2.m2->provider.m3->provider.m1"),
expectedError: errors.New("could not instantiate middleware provider@m1: recursion detected in provider@m1->provider2@m2->provider@m3->provider@m1"),
},
{
buildChain: []string{"ok", "m0"},
@ -261,7 +261,7 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
ctx := context.Background()
if len(test.contextProvider) > 0 {
ctx = internal.AddProviderInContext(ctx, test.contextProvider+".foobar")
ctx = internal.AddProviderInContext(ctx, test.contextProvider+"@foobar")
}
rtConf := config.NewRuntimeConfig(config.Configuration{