From 135f4f54fbda71dc83bb50ea6869fff49b52a7cd Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Sun, 20 Oct 2024 20:16:29 -0700 Subject: [PATCH] fix: populate default configuration values correctly --- CHANGELOG.md | 2 ++ cli/options.go | 14 ++++++++++++++ features/file_config.testfile | 2 ++ rpc/rpc.go | 11 ++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5873940..6826c0c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master +- Fix regression with no populating all default configuration values. ([@palkan][]) + ## 1.5.5 (2024-10-16) - Fix configuration parameters precedence (file -> env -> CLI). ([@palkan][]) diff --git a/cli/options.go b/cli/options.go index f2197d90..38b0ea71 100644 --- a/cli/options.go +++ b/cli/options.go @@ -1326,6 +1326,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal int) error { *dest = setVal @@ -1342,6 +1344,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal int64) error { *dest = setVal @@ -1358,6 +1362,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal float64) error { *dest = setVal @@ -1374,6 +1380,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal time.Duration) error { *dest = setVal @@ -1390,6 +1398,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal bool) error { *dest = setVal @@ -1406,6 +1416,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal string) error { *dest = setVal @@ -1422,6 +1434,8 @@ func withDefaults(category string, flags []cli.Flag) []cli.Flag { dest := v.Destination v.Destination = nil + *dest = v.Value + if v.Action == nil { v.Action = func(ctx *cli.Context, setVal string) error { *dest = setVal diff --git a/features/file_config.testfile b/features/file_config.testfile index 438976b7..b08db44e 100644 --- a/features/file_config.testfile +++ b/features/file_config.testfile @@ -32,6 +32,8 @@ assert_equal("sse.enabled", true, config.dig("sse", "enabled")) assert_equal("metrics.tags", {"env" => "production", "node_id" => "xyz"}, config.dig("metrics", "tags")) assert_equal("metrics.statsd.host", "localhost:8125", config.dig("metrics", "statsd", "host")) assert_equal("metrics.statsd.tags_format", "datadog", config.dig("metrics", "statsd", "tags_format")) +# defaults +assert_equal("rpc.proxy_headers", ["cookie"], config.dig("rpc", "proxy_headers")) if $errors.any? fail $errors.join("\n") diff --git a/rpc/rpc.go b/rpc/rpc.go index c7b8c167..375c17c1 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -6,6 +6,7 @@ import ( "fmt" "log/slog" "math" + "strings" "sync" "sync/atomic" "time" @@ -233,7 +234,15 @@ func (c *Controller) Start() error { client, state, err := dialer(c.config, c.log) if err == nil { - c.log.Info(fmt.Sprintf("RPC controller initialized: %s (concurrency: %s, impl: %s, enable_tls: %t, proto_versions: %s)", host, c.barrier.CapacityInfo(), impl, enableTLS, ProtoVersions)) + proxiedHeaders := strings.Join(c.config.ProxyHeaders, ",") + if proxiedHeaders == "" { + proxiedHeaders = "" + } + proxiedCookies := strings.Join(c.config.ProxyCookies, ",") + if proxiedCookies == "" { + proxiedCookies = "" + } + c.log.Info(fmt.Sprintf("RPC controller initialized: %s (concurrency: %s, impl: %s, enable_tls: %t, proto_versions: %s, proxy_headers: %s, proxy_cookies: %s)", host, c.barrier.CapacityInfo(), impl, enableTLS, ProtoVersions, proxiedHeaders, proxiedCookies)) } else { return err }