mirror of https://github.com/status-im/consul.git
Avoid sending zero-value upstream defaults from api
This commit is contained in:
parent
a6388c7e2f
commit
ab752c1c86
|
@ -194,7 +194,9 @@ func (cfg *ConnectConfiguration) Normalize() {
|
||||||
v.Normalize()
|
v.Normalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.UpstreamDefaults.Normalize()
|
if cfg.UpstreamDefaults != nil {
|
||||||
|
cfg.UpstreamDefaults.Normalize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg ConnectConfiguration) Validate() error {
|
func (cfg ConnectConfiguration) Validate() error {
|
||||||
|
@ -206,8 +208,11 @@ func (cfg ConnectConfiguration) Validate() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cfg.UpstreamDefaults.Validate(); err != nil {
|
if cfg.UpstreamDefaults != nil {
|
||||||
validationErr = multierror.Append(validationErr, fmt.Errorf("error in upstream defaults %v", err))
|
err := cfg.UpstreamDefaults.Validate()
|
||||||
|
if err != nil {
|
||||||
|
validationErr = multierror.Append(validationErr, fmt.Errorf("error in upstream defaults %v", err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return validationErr
|
return validationErr
|
||||||
|
|
|
@ -98,7 +98,7 @@ type ConnectConfiguration struct {
|
||||||
UpstreamConfigs map[string]UpstreamConfig `json:",omitempty" alias:"upstream_configs"`
|
UpstreamConfigs map[string]UpstreamConfig `json:",omitempty" alias:"upstream_configs"`
|
||||||
|
|
||||||
// UpstreamDefaults contains default configuration for all upstreams of a given service
|
// 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 {
|
type UpstreamConfig struct {
|
||||||
|
|
|
@ -638,7 +638,7 @@ func TestParseConfigEntry(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UpstreamDefaults: api.UpstreamConfig{
|
UpstreamDefaults: &api.UpstreamConfig{
|
||||||
EnvoyClusterJSON: "zip",
|
EnvoyClusterJSON: "zip",
|
||||||
EnvoyListenerJSON: "zop",
|
EnvoyListenerJSON: "zop",
|
||||||
Protocol: "http",
|
Protocol: "http",
|
||||||
|
|
Loading…
Reference in New Issue