1
0
Fork 0

Move dynamic config into a dedicated package.

This commit is contained in:
Ludovic Fernandez 2019-07-10 09:26:04 +02:00 committed by Traefiker Bot
parent 09cc1161c9
commit c8bf8e896a
102 changed files with 3170 additions and 3166 deletions

View file

@ -6,7 +6,7 @@ import (
"fmt"
"net/http"
"github.com/containous/traefik/pkg/config"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/ip"
"github.com/containous/traefik/pkg/middlewares"
"github.com/containous/traefik/pkg/tracing"
@ -27,7 +27,7 @@ type ipWhiteLister struct {
}
// New builds a new IPWhiteLister given a list of CIDR-Strings to whitelist
func New(ctx context.Context, next http.Handler, config config.IPWhiteList, name string) (http.Handler, error) {
func New(ctx context.Context, next http.Handler, config dynamic.IPWhiteList, name string) (http.Handler, error) {
logger := middlewares.GetLogger(ctx, name, typeName)
logger.Debug("Creating middleware")

View file

@ -6,7 +6,7 @@ import (
"net/http/httptest"
"testing"
"github.com/containous/traefik/pkg/config"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -14,19 +14,19 @@ import (
func TestNewIPWhiteLister(t *testing.T) {
testCases := []struct {
desc string
whiteList config.IPWhiteList
whiteList dynamic.IPWhiteList
expectedError bool
}{
{
desc: "invalid IP",
whiteList: config.IPWhiteList{
whiteList: dynamic.IPWhiteList{
SourceRange: []string{"foo"},
},
expectedError: true,
},
{
desc: "valid IP",
whiteList: config.IPWhiteList{
whiteList: dynamic.IPWhiteList{
SourceRange: []string{"10.10.10.10"},
},
},
@ -53,13 +53,13 @@ func TestNewIPWhiteLister(t *testing.T) {
func TestIPWhiteLister_ServeHTTP(t *testing.T) {
testCases := []struct {
desc string
whiteList config.IPWhiteList
whiteList dynamic.IPWhiteList
remoteAddr string
expected int
}{
{
desc: "authorized with remote address",
whiteList: config.IPWhiteList{
whiteList: dynamic.IPWhiteList{
SourceRange: []string{"20.20.20.20"},
},
remoteAddr: "20.20.20.20:1234",
@ -67,7 +67,7 @@ func TestIPWhiteLister_ServeHTTP(t *testing.T) {
},
{
desc: "non authorized with remote address",
whiteList: config.IPWhiteList{
whiteList: dynamic.IPWhiteList{
SourceRange: []string{"20.20.20.20"},
},
remoteAddr: "20.20.20.21:1234",