Merge branch 'v1.5' into master
This commit is contained in:
commit
c8446c2dc8
40 changed files with 493 additions and 234 deletions
|
@ -62,10 +62,10 @@ const (
|
|||
pathFrontendRoutes = "/routes/"
|
||||
pathFrontendRule = "/rule"
|
||||
|
||||
pathTLSConfiguration = "/tlsconfiguration/"
|
||||
pathTLSConfigurationEntryPoints = "/entrypoints"
|
||||
pathTLSConfigurationCertFile = "/certificate/certfile"
|
||||
pathTLSConfigurationKeyFile = "/certificate/keyfile"
|
||||
pathTLS = "/tls/"
|
||||
pathTLSEntryPoints = "/entrypoints"
|
||||
pathTLSCertFile = "/certificate/certfile"
|
||||
pathTLSKeyFile = "/certificate/keyfile"
|
||||
|
||||
pathTags = "/tags"
|
||||
pathAlias = "/alias"
|
||||
|
|
|
@ -38,7 +38,7 @@ func (p *Provider) buildConfiguration() *types.Configuration {
|
|||
"Last": p.last,
|
||||
"Has": p.has,
|
||||
|
||||
"getTLSConfigurations": p.getTLSConfigurations,
|
||||
"getTLSSection": p.getTLSSection,
|
||||
|
||||
// Frontend functions
|
||||
"getBackendName": p.getFuncString(pathFrontendBackend, ""),
|
||||
|
@ -273,19 +273,19 @@ func (p *Provider) getHealthCheck(rootPath string) *types.HealthCheck {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *Provider) getTLSConfigurations(prefix string) []*tls.Configuration {
|
||||
var tlsConfiguration []*tls.Configuration
|
||||
func (p *Provider) getTLSSection(prefix string) []*tls.Configuration {
|
||||
var tlsSection []*tls.Configuration
|
||||
|
||||
for _, tlsConfPath := range p.list(prefix, pathTLSConfiguration) {
|
||||
certFile := p.get("", tlsConfPath, pathTLSConfigurationCertFile)
|
||||
keyFile := p.get("", tlsConfPath, pathTLSConfigurationKeyFile)
|
||||
for _, tlsConfPath := range p.list(prefix, pathTLS) {
|
||||
certFile := p.get("", tlsConfPath, pathTLSCertFile)
|
||||
keyFile := p.get("", tlsConfPath, pathTLSKeyFile)
|
||||
|
||||
if len(certFile) == 0 && len(keyFile) == 0 {
|
||||
log.Warnf("Invalid TLS configuration (no cert and no key): %s", tlsConfPath)
|
||||
continue
|
||||
}
|
||||
|
||||
entryPoints := p.getList(tlsConfPath, pathTLSConfigurationEntryPoints)
|
||||
entryPoints := p.getList(tlsConfPath, pathTLSEntryPoints)
|
||||
if len(entryPoints) == 0 {
|
||||
log.Warnf("Invalid TLS configuration (no entry points): %s", tlsConfPath)
|
||||
continue
|
||||
|
@ -299,10 +299,10 @@ func (p *Provider) getTLSConfigurations(prefix string) []*tls.Configuration {
|
|||
},
|
||||
}
|
||||
|
||||
tlsConfiguration = append(tlsConfiguration, tlsConf)
|
||||
tlsSection = append(tlsSection, tlsConf)
|
||||
}
|
||||
|
||||
return tlsConfiguration
|
||||
return tlsSection
|
||||
}
|
||||
|
||||
func (p *Provider) getRoutes(rootPath string) map[string]types.Route {
|
||||
|
|
|
@ -125,11 +125,11 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
|
||||
withPair("routes/route1/rule", "Host:test.localhost"),
|
||||
withPair("routes/route2/rule", "Path:/foo")),
|
||||
entry("tlsconfiguration/foo",
|
||||
entry("tls/foo",
|
||||
withPair("entrypoints", "http,https"),
|
||||
withPair("certificate/certfile", "certfile1"),
|
||||
withPair("certificate/keyfile", "keyfile1")),
|
||||
entry("tlsconfiguration/bar",
|
||||
entry("tls/bar",
|
||||
withPair("entrypoints", "http,https"),
|
||||
withPair("certificate/certfile", "certfile2"),
|
||||
withPair("certificate/keyfile", "keyfile2")),
|
||||
|
@ -246,7 +246,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLSConfiguration: []*tls.Configuration{
|
||||
TLS: []*tls.Configuration{
|
||||
{
|
||||
EntryPoints: []string{"http", "https"},
|
||||
Certificate: &tls.Certificate{
|
||||
|
@ -1700,7 +1700,7 @@ func TestProviderGetHealthCheck(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestProviderGetTLSConfigurations(t *testing.T) {
|
||||
func TestProviderGetTLSes(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
kvPairs []*store.KVPair
|
||||
|
@ -1709,11 +1709,11 @@ func TestProviderGetTLSConfigurations(t *testing.T) {
|
|||
{
|
||||
desc: "when several TLS configuration defined",
|
||||
kvPairs: filler("traefik",
|
||||
entry("tlsconfiguration/foo",
|
||||
entry("tls/foo",
|
||||
withPair("entrypoints", "http,https"),
|
||||
withPair("certificate/certfile", "certfile1"),
|
||||
withPair("certificate/keyfile", "keyfile1")),
|
||||
entry("tlsconfiguration/bar",
|
||||
entry("tls/bar",
|
||||
withPair("entrypoints", "http,https"),
|
||||
withPair("certificate/certfile", "certfile2"),
|
||||
withPair("certificate/keyfile", "keyfile2"))),
|
||||
|
@ -1736,13 +1736,13 @@ func TestProviderGetTLSConfigurations(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "should return nil when no TLS configuration",
|
||||
kvPairs: filler("traefik", entry("tlsconfiguration/foo")),
|
||||
kvPairs: filler("traefik", entry("tls/foo")),
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
desc: "should return nil when no entry points",
|
||||
kvPairs: filler("traefik",
|
||||
entry("tlsconfiguration/foo",
|
||||
entry("tls/foo",
|
||||
withPair("certificate/certfile", "certfile2"),
|
||||
withPair("certificate/keyfile", "keyfile2"))),
|
||||
expected: nil,
|
||||
|
@ -1750,7 +1750,7 @@ func TestProviderGetTLSConfigurations(t *testing.T) {
|
|||
{
|
||||
desc: "should return nil when no cert file and no key file",
|
||||
kvPairs: filler("traefik",
|
||||
entry("tlsconfiguration/foo",
|
||||
entry("tls/foo",
|
||||
withPair("entrypoints", "http,https"))),
|
||||
expected: nil,
|
||||
},
|
||||
|
@ -1764,7 +1764,7 @@ func TestProviderGetTLSConfigurations(t *testing.T) {
|
|||
|
||||
p := newProviderMock(test.kvPairs)
|
||||
|
||||
result := p.getTLSConfigurations(prefix)
|
||||
result := p.getTLSSection(prefix)
|
||||
|
||||
assert.Equal(t, test.expected, result)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue