From 96ffc3bf3fcffcf9f7483cd9a6790d6de7c9a3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Wed, 12 Feb 2025 20:30:12 +0100 Subject: [PATCH] config: multiple web.listen-address args results into an error, if --config.file is defined. (#1876) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- cmd/windows_exporter/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/windows_exporter/main.go b/cmd/windows_exporter/main.go index 82c59bb7..a652160f 100644 --- a/cmd/windows_exporter/main.go +++ b/cmd/windows_exporter/main.go @@ -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", @@ -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