Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ var (
Help: "Timestamp of the last successful configuration reload.",
})

cfg *ini.File

opts = ini.LoadOptions{
// Do not error on nonexistent file to allow empty string as filename input
Loose: true,
Expand Down Expand Up @@ -97,12 +95,13 @@ func (ch *MySqlConfigHandler) ReloadConfig(filename string, mysqldAddress string
}
}()

if cfg, err = ini.LoadSources(
cfg, err := ini.LoadSources(
opts,
[]byte("[client]\npassword = ${MYSQLD_EXPORTER_PASSWORD}\n"),
filename,
); err != nil {
return fmt.Errorf("failed to load %s: %w", filename, err)
)
if err != nil {
return fmt.Errorf("failed to load config from %s: %w", filename, err)
}

if host, port, err = net.SplitHostPort(mysqldAddress); err != nil {
Expand Down Expand Up @@ -135,12 +134,6 @@ func (ch *MySqlConfigHandler) ReloadConfig(filename string, mysqldAddress string
TlsInsecureSkipVerify: tlsInsecureSkipVerify,
}

// FIXME: this error check seems orphaned
if err != nil {
level.Error(logger).Log("msg", "failed to load config", "section", sectionName, "err", err)
continue
}

err = sec.StrictMapTo(mysqlcfg)
if err != nil {
level.Error(logger).Log("msg", "failed to parse config", "section", sectionName, "err", err)
Expand Down