Skip to content

Commit

Permalink
config: multiple web.listen-address args results into an error, if --…
Browse files Browse the repository at this point in the history
…config.file is defined. (#1876)

Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke authored Feb 12, 2025
1 parent 285c4cc commit 96ffc3b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/windows_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ func run() int {
return 1
}

// NOTE: This is temporary fix for issue #1092, calling kingpin.Parse
// twice makes slices flags duplicate its value, this clean up
// the first parse before the second call.
*webConfig.WebListenAddresses = (*webConfig.WebListenAddresses)[1:]

// Parse flags once more to include those discovered in configuration file(s).
if _, err = app.Parse(os.Args[1:]); err != nil {
logger.ErrorContext(ctx, "failed to parse CLI args from YAML file",
Expand All @@ -177,6 +172,12 @@ func run() int {
return 1
}

// NOTE: This is temporary fix for issue #1092, calling kingpin.Parse
// twice makes slices flags duplicate its value, this clean up
// the first parse before the second call.
slices.Sort(*webConfig.WebListenAddresses)
*webConfig.WebListenAddresses = slices.Clip(slices.Compact(*webConfig.WebListenAddresses))

logger, err = log.New(logConfig)
if err != nil {
//nolint:sloglint // we do not have an logger yet
Expand Down

0 comments on commit 96ffc3b

Please sign in to comment.