mirror of https://github.com/status-im/consul.git
agent: adding EnableDebug config
This commit is contained in:
parent
7d4e099566
commit
528053c7a3
|
@ -100,6 +100,9 @@ type Config struct {
|
||||||
// Protocol is the Consul protocol version to use.
|
// Protocol is the Consul protocol version to use.
|
||||||
Protocol int `mapstructure:"protocol"`
|
Protocol int `mapstructure:"protocol"`
|
||||||
|
|
||||||
|
// EnableDebug is used to enable various debugging features
|
||||||
|
EnableDebug bool `mapstructure:"enable_debug"`
|
||||||
|
|
||||||
// Checks holds the provided check definitions
|
// Checks holds the provided check definitions
|
||||||
Checks []*CheckDefinition `mapstructure:"-"`
|
Checks []*CheckDefinition `mapstructure:"-"`
|
||||||
|
|
||||||
|
@ -321,6 +324,9 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
if b.SkipLeaveOnInt == true {
|
if b.SkipLeaveOnInt == true {
|
||||||
result.SkipLeaveOnInt = true
|
result.SkipLeaveOnInt = true
|
||||||
}
|
}
|
||||||
|
if b.EnableDebug {
|
||||||
|
result.EnableDebug = true
|
||||||
|
}
|
||||||
if b.Checks != nil {
|
if b.Checks != nil {
|
||||||
result.Checks = append(result.Checks, b.Checks...)
|
result.Checks = append(result.Checks, b.Checks...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,17 @@ func TestDecodeConfig(t *testing.T) {
|
||||||
if config.SkipLeaveOnInt != true {
|
if config.SkipLeaveOnInt != true {
|
||||||
t.Fatalf("bad: %#v", config)
|
t.Fatalf("bad: %#v", config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enable_debug
|
||||||
|
input = `{"enable_debug": true}`
|
||||||
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.EnableDebug != true {
|
||||||
|
t.Fatalf("bad: %#v", config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodeConfig_Service(t *testing.T) {
|
func TestDecodeConfig_Service(t *testing.T) {
|
||||||
|
@ -284,6 +295,7 @@ func TestMergeConfig(t *testing.T) {
|
||||||
Server: false,
|
Server: false,
|
||||||
LeaveOnTerm: false,
|
LeaveOnTerm: false,
|
||||||
SkipLeaveOnInt: false,
|
SkipLeaveOnInt: false,
|
||||||
|
EnableDebug: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
b := &Config{
|
b := &Config{
|
||||||
|
@ -305,6 +317,7 @@ func TestMergeConfig(t *testing.T) {
|
||||||
Server: true,
|
Server: true,
|
||||||
LeaveOnTerm: true,
|
LeaveOnTerm: true,
|
||||||
SkipLeaveOnInt: true,
|
SkipLeaveOnInt: true,
|
||||||
|
EnableDebug: true,
|
||||||
Checks: []*CheckDefinition{nil},
|
Checks: []*CheckDefinition{nil},
|
||||||
Services: []*ServiceDefinition{nil},
|
Services: []*ServiceDefinition{nil},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue