Send empty configuration from file provider
This commit is contained in:
parent
e8333883df
commit
9a7821b8fa
2 changed files with 28 additions and 23 deletions
|
@ -590,7 +590,7 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithTlsConfigurationDeletion(c
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, http.StatusResetContent)
|
c.Assert(resp.StatusCode, checker.Equals, http.StatusResetContent)
|
||||||
// Change certificates configuration file content
|
// Change certificates configuration file content
|
||||||
modifyCertificateConfFileContent(c, "snitest.com", dynamicConfFileName, "https02")
|
modifyCertificateConfFileContent(c, "", dynamicConfFileName, "https02")
|
||||||
|
|
||||||
err = try.Do(60*time.Second, func() error {
|
err = try.Do(60*time.Second, func() error {
|
||||||
resp, err = client.Do(req)
|
resp, err = client.Do(req)
|
||||||
|
@ -615,6 +615,14 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithTlsConfigurationDeletion(c
|
||||||
|
|
||||||
// modifyCertificateConfFileContent replaces the content of a HTTPS configuration file.
|
// modifyCertificateConfFileContent replaces the content of a HTTPS configuration file.
|
||||||
func modifyCertificateConfFileContent(c *check.C, certFileName, confFileName, entryPoint string) {
|
func modifyCertificateConfFileContent(c *check.C, certFileName, confFileName, entryPoint string) {
|
||||||
|
f, err := os.OpenFile("./"+confFileName, os.O_WRONLY, os.ModeExclusive)
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer func() {
|
||||||
|
f.Close()
|
||||||
|
}()
|
||||||
|
f.Truncate(0)
|
||||||
|
// If certificate file is not provided, just truncate the configuration file
|
||||||
|
if len(certFileName) > 0 {
|
||||||
tlsConf := types.Configuration{
|
tlsConf := types.Configuration{
|
||||||
TLSConfiguration: []*traefikTls.Configuration{
|
TLSConfiguration: []*traefikTls.Configuration{
|
||||||
{
|
{
|
||||||
|
@ -631,12 +639,7 @@ func modifyCertificateConfFileContent(c *check.C, certFileName, confFileName, en
|
||||||
err := e.Encode(tlsConf)
|
err := e.Encode(tlsConf)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
f, err := os.OpenFile("./"+confFileName, os.O_WRONLY, os.ModeExclusive)
|
|
||||||
c.Assert(err, checker.IsNil)
|
|
||||||
defer func() {
|
|
||||||
f.Close()
|
|
||||||
}()
|
|
||||||
f.Truncate(0)
|
|
||||||
_, err = f.Write(confBuffer.Bytes())
|
_, err = f.Write(confBuffer.Bytes())
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,10 @@ func sendConfigToChannel(configurationChan chan<- types.ConfigMessage, configura
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadFileConfig(filename string) (*types.Configuration, error) {
|
func loadFileConfig(filename string) (*types.Configuration, error) {
|
||||||
configuration := new(types.Configuration)
|
configuration := &types.Configuration{
|
||||||
|
Frontends: make(map[string]*types.Frontend),
|
||||||
|
Backends: make(map[string]*types.Backend),
|
||||||
|
}
|
||||||
if _, err := toml.DecodeFile(filename, configuration); err != nil {
|
if _, err := toml.DecodeFile(filename, configuration); err != nil {
|
||||||
return nil, fmt.Errorf("error reading configuration file: %s", err)
|
return nil, fmt.Errorf("error reading configuration file: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -144,7 +147,6 @@ func loadFileConfigFromDirectory(directory string, configuration *types.Configur
|
||||||
configuration = &types.Configuration{
|
configuration = &types.Configuration{
|
||||||
Frontends: make(map[string]*types.Frontend),
|
Frontends: make(map[string]*types.Frontend),
|
||||||
Backends: make(map[string]*types.Backend),
|
Backends: make(map[string]*types.Backend),
|
||||||
TLSConfiguration: make([]*tls.Configuration, 0),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue