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

@ -11,7 +11,7 @@ import (
"net/url"
"strings"
"github.com/containous/traefik/pkg/config"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/log"
"github.com/containous/traefik/pkg/middlewares"
"github.com/containous/traefik/pkg/tracing"
@ -40,7 +40,7 @@ type DistinguishedNameOptions struct {
StateOrProvinceName bool
}
func newDistinguishedNameOptions(info *config.TLSCLientCertificateDNInfo) *DistinguishedNameOptions {
func newDistinguishedNameOptions(info *dynamic.TLSCLientCertificateDNInfo) *DistinguishedNameOptions {
if info == nil {
return nil
}
@ -65,7 +65,7 @@ type passTLSClientCert struct {
}
// New constructs a new PassTLSClientCert instance from supplied frontend header struct.
func New(ctx context.Context, next http.Handler, config config.PassTLSClientCert, name string) (http.Handler, error) {
func New(ctx context.Context, next http.Handler, config dynamic.PassTLSClientCert, name string) (http.Handler, error) {
middlewares.GetLogger(ctx, name, typeName).Debug("Creating middleware")
return &passTLSClientCert{
@ -85,7 +85,7 @@ type tlsClientCertificateInfo struct {
issuer *DistinguishedNameOptions
}
func newTLSClientInfo(info *config.TLSClientCertificateInfo) *tlsClientCertificateInfo {
func newTLSClientInfo(info *dynamic.TLSClientCertificateInfo) *tlsClientCertificateInfo {
if info == nil {
return nil
}

View file

@ -13,7 +13,7 @@ import (
"strings"
"testing"
"github.com/containous/traefik/pkg/config"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/testhelpers"
"github.com/stretchr/testify/require"
)
@ -367,7 +367,7 @@ func TestTLSClientHeadersWithPEM(t *testing.T) {
testCases := []struct {
desc string
certContents []string // set the request TLS attribute if defined
config config.PassTLSClientCert
config dynamic.PassTLSClientCert
expectedHeader string
}{
{
@ -379,24 +379,24 @@ func TestTLSClientHeadersWithPEM(t *testing.T) {
},
{
desc: "No TLS, with pem option true",
config: config.PassTLSClientCert{PEM: true},
config: dynamic.PassTLSClientCert{PEM: true},
},
{
desc: "TLS with simple certificate, with pem option true",
certContents: []string{minimalCheeseCrt},
config: config.PassTLSClientCert{PEM: true},
config: dynamic.PassTLSClientCert{PEM: true},
expectedHeader: getCleanCertContents([]string{minimalCert}),
},
{
desc: "TLS with complete certificate, with pem option true",
certContents: []string{minimalCheeseCrt},
config: config.PassTLSClientCert{PEM: true},
config: dynamic.PassTLSClientCert{PEM: true},
expectedHeader: getCleanCertContents([]string{minimalCheeseCrt}),
},
{
desc: "TLS with two certificate, with pem option true",
certContents: []string{minimalCert, minimalCheeseCrt},
config: config.PassTLSClientCert{PEM: true},
config: dynamic.PassTLSClientCert{PEM: true},
expectedHeader: getCleanCertContents([]string{minimalCert, minimalCheeseCrt}),
},
}
@ -488,7 +488,7 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
testCases := []struct {
desc string
certContents []string // set the request TLS attribute if defined
config config.PassTLSClientCert
config dynamic.PassTLSClientCert
expectedHeader string
}{
{
@ -500,9 +500,9 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
},
{
desc: "No TLS, with subject info",
config: config.PassTLSClientCert{
Info: &config.TLSClientCertificateInfo{
Subject: &config.TLSCLientCertificateDNInfo{
config: dynamic.PassTLSClientCert{
Info: &dynamic.TLSClientCertificateInfo{
Subject: &dynamic.TLSCLientCertificateDNInfo{
CommonName: true,
Organization: true,
Locality: true,
@ -515,22 +515,22 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
},
{
desc: "No TLS, with pem option false with empty subject info",
config: config.PassTLSClientCert{
config: dynamic.PassTLSClientCert{
PEM: false,
Info: &config.TLSClientCertificateInfo{
Subject: &config.TLSCLientCertificateDNInfo{},
Info: &dynamic.TLSClientCertificateInfo{
Subject: &dynamic.TLSCLientCertificateDNInfo{},
},
},
},
{
desc: "TLS with simple certificate, with all info",
certContents: []string{minimalCheeseCrt},
config: config.PassTLSClientCert{
Info: &config.TLSClientCertificateInfo{
config: dynamic.PassTLSClientCert{
Info: &dynamic.TLSClientCertificateInfo{
NotAfter: true,
NotBefore: true,
Sans: true,
Subject: &config.TLSCLientCertificateDNInfo{
Subject: &dynamic.TLSCLientCertificateDNInfo{
CommonName: true,
Country: true,
DomainComponent: true,
@ -539,7 +539,7 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
Province: true,
SerialNumber: true,
},
Issuer: &config.TLSCLientCertificateDNInfo{
Issuer: &dynamic.TLSCLientCertificateDNInfo{
CommonName: true,
Country: true,
DomainComponent: true,
@ -555,14 +555,14 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
{
desc: "TLS with simple certificate, with some info",
certContents: []string{minimalCheeseCrt},
config: config.PassTLSClientCert{
Info: &config.TLSClientCertificateInfo{
config: dynamic.PassTLSClientCert{
Info: &dynamic.TLSClientCertificateInfo{
NotAfter: true,
Sans: true,
Subject: &config.TLSCLientCertificateDNInfo{
Subject: &dynamic.TLSCLientCertificateDNInfo{
Organization: true,
},
Issuer: &config.TLSCLientCertificateDNInfo{
Issuer: &dynamic.TLSCLientCertificateDNInfo{
Country: true,
},
},
@ -572,12 +572,12 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
{
desc: "TLS with complete certificate, with all info",
certContents: []string{completeCheeseCrt},
config: config.PassTLSClientCert{
Info: &config.TLSClientCertificateInfo{
config: dynamic.PassTLSClientCert{
Info: &dynamic.TLSClientCertificateInfo{
NotAfter: true,
NotBefore: true,
Sans: true,
Subject: &config.TLSCLientCertificateDNInfo{
Subject: &dynamic.TLSCLientCertificateDNInfo{
Country: true,
Province: true,
Locality: true,
@ -586,7 +586,7 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
SerialNumber: true,
DomainComponent: true,
},
Issuer: &config.TLSCLientCertificateDNInfo{
Issuer: &dynamic.TLSCLientCertificateDNInfo{
Country: true,
Province: true,
Locality: true,
@ -602,12 +602,12 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
{
desc: "TLS with 2 certificates, with all info",
certContents: []string{minimalCheeseCrt, completeCheeseCrt},
config: config.PassTLSClientCert{
Info: &config.TLSClientCertificateInfo{
config: dynamic.PassTLSClientCert{
Info: &dynamic.TLSClientCertificateInfo{
NotAfter: true,
NotBefore: true,
Sans: true,
Subject: &config.TLSCLientCertificateDNInfo{
Subject: &dynamic.TLSCLientCertificateDNInfo{
Country: true,
Province: true,
Locality: true,
@ -616,7 +616,7 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
SerialNumber: true,
DomainComponent: true,
},
Issuer: &config.TLSCLientCertificateDNInfo{
Issuer: &dynamic.TLSCLientCertificateDNInfo{
Country: true,
Province: true,
Locality: true,