diff --git a/agent/structs/config_entry.go b/agent/structs/config_entry.go index 4c14d5005..a12e6a407 100644 --- a/agent/structs/config_entry.go +++ b/agent/structs/config_entry.go @@ -194,7 +194,9 @@ func (cfg *ConnectConfiguration) Normalize() { v.Normalize() } - cfg.UpstreamDefaults.Normalize() + if cfg.UpstreamDefaults != nil { + cfg.UpstreamDefaults.Normalize() + } } func (cfg ConnectConfiguration) Validate() error { @@ -206,8 +208,11 @@ func (cfg ConnectConfiguration) Validate() error { } } - if err := cfg.UpstreamDefaults.Validate(); err != nil { - validationErr = multierror.Append(validationErr, fmt.Errorf("error in upstream defaults %v", err)) + if cfg.UpstreamDefaults != nil { + err := cfg.UpstreamDefaults.Validate() + if err != nil { + validationErr = multierror.Append(validationErr, fmt.Errorf("error in upstream defaults %v", err)) + } } return validationErr diff --git a/api/config_entry.go b/api/config_entry.go index ed9215efc..bfb853057 100644 --- a/api/config_entry.go +++ b/api/config_entry.go @@ -98,7 +98,7 @@ type ConnectConfiguration struct { UpstreamConfigs map[string]UpstreamConfig `json:",omitempty" alias:"upstream_configs"` // UpstreamDefaults contains default configuration for all upstreams of a given service - UpstreamDefaults UpstreamConfig `json:",omitempty" alias:"upstream_defaults"` + UpstreamDefaults *UpstreamConfig `json:",omitempty" alias:"upstream_defaults"` } type UpstreamConfig struct { diff --git a/command/config/write/config_write_test.go b/command/config/write/config_write_test.go index 9a9597e31..3beebbe07 100644 --- a/command/config/write/config_write_test.go +++ b/command/config/write/config_write_test.go @@ -638,7 +638,7 @@ func TestParseConfigEntry(t *testing.T) { }, }, }, - UpstreamDefaults: api.UpstreamConfig{ + UpstreamDefaults: &api.UpstreamConfig{ EnvoyClusterJSON: "zip", EnvoyListenerJSON: "zop", Protocol: "http",