diff --git a/changelog/9109.txt b/changelog/9109.txt new file mode 100644 index 000000000..c85db60b0 --- /dev/null +++ b/changelog/9109.txt @@ -0,0 +1,3 @@ +```release-note:improvement +core: Add support for go-sockaddr templated addresses in config. +``` diff --git a/command/server/config.go b/command/server/config.go index df6938755..c478906a7 100644 --- a/command/server/config.go +++ b/command/server/config.go @@ -392,6 +392,17 @@ func ParseConfig(d, source string) (*Config, error) { return nil, err } + if rendered, err := configutil.ParseSingleIPTemplate(result.APIAddr); err != nil { + return nil, err + } else { + result.APIAddr = rendered + } + if rendered, err := configutil.ParseSingleIPTemplate(result.ClusterAddr); err != nil { + return nil, err + } else { + result.ClusterAddr = rendered + } + sharedConfig, err := configutil.ParseConfig(d) if err != nil { return nil, err diff --git a/command/server/config_test.go b/command/server/config_test.go index db6364c83..8ba8d260d 100644 --- a/command/server/config_test.go +++ b/command/server/config_test.go @@ -36,6 +36,10 @@ func TestParseListeners(t *testing.T) { testParseListeners(t) } +func TestParseSockaddrTemplate(t *testing.T) { + testParseSockaddrTemplate(t) +} + func TestConfigRaftRetryJoin(t *testing.T) { testConfigRaftRetryJoin(t) } diff --git a/command/server/config_test_helpers.go b/command/server/config_test_helpers.go index 8936a0244..d6c728340 100644 --- a/command/server/config_test_helpers.go +++ b/command/server/config_test_helpers.go @@ -843,6 +843,43 @@ listener "tcp" { } } +func testParseSockaddrTemplate(t *testing.T) { + config, err := ParseConfig(` +api_addr = <