Merge pull request #436 from Icinga/tls-options-not-applied

Fix currently not able to enable TLS
This commit is contained in:
Eric Lippmann 2022-02-03 16:56:37 +01:00 committed by GitHub
commit ccde290c8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 15 deletions

View file

@ -83,7 +83,7 @@ func ParseFlags() (*Flags, error) {
// TLS provides TLS configuration options for Redis and Database.
type TLS struct {
Tls bool `yaml:"tls"`
Enable bool `yaml:"tls"`
Cert string `yaml:"cert"`
Key string `yaml:"key"`
Ca string `yaml:"ca"`
@ -92,7 +92,7 @@ type TLS struct {
// MakeConfig assembles a tls.Config from t and address.
func (t *TLS) MakeConfig(address string) (*tls.Config, error) {
if !t.Tls {
if !t.Enable {
return nil, nil
}

View file

@ -19,13 +19,13 @@ var registerDriverOnce sync.Once
// Database defines database client configuration.
type Database struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Database string `yaml:"database"`
User string `yaml:"user"`
Password string `yaml:"password"`
TLS `yaml:",inline"`
Options icingadb.Options `yaml:"options"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Database string `yaml:"database"`
User string `yaml:"user"`
Password string `yaml:"password"`
TlsOptions TLS `yaml:",inline"`
Options icingadb.Options `yaml:"options"`
}
// Open prepares the DSN string and driver configuration,
@ -44,7 +44,7 @@ func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) {
config.DBName = d.Database
config.Timeout = time.Minute
tlsConfig, err := d.TLS.MakeConfig(config.Addr)
tlsConfig, err := d.TlsOptions.MakeConfig(config.Addr)
if err != nil {
return nil, err
}

View file

@ -19,10 +19,10 @@ import (
// Redis defines Redis client configuration.
type Redis struct {
Address string `yaml:"address"`
Password string `yaml:"password"`
TLS `yaml:",inline"`
Options icingaredis.Options `yaml:"options"`
Address string `yaml:"address"`
Password string `yaml:"password"`
TlsOptions TLS `yaml:",inline"`
Options icingaredis.Options `yaml:"options"`
}
type ctxDialerFunc = func(ctx context.Context, network, addr string) (net.Conn, error)
@ -30,7 +30,7 @@ type ctxDialerFunc = func(ctx context.Context, network, addr string) (net.Conn,
// NewClient prepares Redis client configuration,
// calls redis.NewClient, but returns *icingaredis.Client.
func (r *Redis) NewClient(logger *logging.Logger) (*icingaredis.Client, error) {
tlsConfig, err := r.TLS.MakeConfig(r.Address)
tlsConfig, err := r.TlsOptions.MakeConfig(r.Address)
if err != nil {
return nil, err
}