Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
fix: populate default configuration values correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Oct 21, 2024
1 parent 1fa6c44 commit 135f4f5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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][])
Expand Down
14 changes: 14 additions & 0 deletions cli/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions features/file_config.testfile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 10 additions & 1 deletion rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"math"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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 = "<none>"
}
proxiedCookies := strings.Join(c.config.ProxyCookies, ",")
if proxiedCookies == "" {
proxiedCookies = "<all>"
}
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
}
Expand Down

0 comments on commit 135f4f5

Please sign in to comment.