Skip to content

Commit fdffd1b

Browse files
committed
Debugging
1 parent ea80386 commit fdffd1b

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

haproxy.tmpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ global
55
defaults
66
mode http
77
balance roundrobin
8-
9-
option dontlognull
10-
option dontlog-normal
8+
{{.ExtraDefaults}}
119
option http-server-close
1210
option forwardfor
1311
option redispatch

proxy/ha_proxy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type ConfigData struct {
2929
StatsPass string
3030
UserList string
3131
ExtraGlobal string
32+
ExtraDefaults string
3233
}
3334

3435
func NewHaProxy(templatesPath, configsPath string, certs map[string]bool) Proxy {
@@ -196,6 +197,10 @@ func (m HaProxy) getConfigData() ConfigData {
196197
if strings.EqualFold(os.Getenv("DEBUG"), "true") {
197198
d.ExtraGlobal += `
198199
debug`
200+
} else {
201+
d.ExtraDefaults += `
202+
option dontlognull
203+
option dontlog-normal`
199204
}
200205
return d
201206
}

proxy/ha_proxy_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsDebug() {
176176
defer func() { os.Setenv("DEBUG", debugOrig) }()
177177
os.Setenv("DEBUG", "true")
178178
var actualData string
179+
tmpl := strings.Replace(s.TemplateContent, "tune.ssl.default-dh-param 2048", "tune.ssl.default-dh-param 2048\n debug", -1)
180+
tmpl = strings.Replace(tmpl," option dontlognull\n option dontlog-normal\n", "", -1)
179181
expectedData := fmt.Sprintf(
180182
"%s%s",
181-
strings.Replace(s.TemplateContent, "tune.ssl.default-dh-param 2048", "tune.ssl.default-dh-param 2048\n debug", -1),
183+
tmpl,
182184
s.ServicesContent,
183185
)
184186
writeFile = func(filename string, data []byte, perm os.FileMode) error {

proxy/test_configs/tmpl/haproxy.tmpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ global
55
defaults
66
mode http
77
balance roundrobin
8-
9-
option dontlognull
10-
option dontlog-normal
8+
{{.ExtraDefaults}}
119
option http-server-close
1210
option forwardfor
1311
option redispatch

0 commit comments

Comments
 (0)