Skip to content

Commit 5c55e55

Browse files
author
Greg Dubicki
committed
Add haproxy prefix where applicable
1 parent 2c7e3dd commit 5c55e55

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

haproxy/haproxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ func (h *HAProxy) start(sd *lib.Shutdown) error {
6060
}
6161
h.haConfig = hc
6262

63-
if h.opts.LogAddress == "" {
63+
if h.opts.HAProxyLogAddress == "" {
6464
err := h.startLogger()
6565
if err != nil {
6666
return err
6767
}
6868
} else {
69-
log.Infof("not starting built-in syslog - using %s as syslog address", h.opts.LogAddress)
69+
log.Infof("not starting built-in syslog - using %s as syslog address", h.opts.HAProxyLogAddress)
7070
}
7171

7272
if h.opts.EnableIntentions {
@@ -79,7 +79,7 @@ func (h *HAProxy) start(sd *lib.Shutdown) error {
7979
dpc, err := haproxy_cmd.Start(sd, haproxy_cmd.Config{
8080
HAProxyPath: h.opts.HAProxyBin,
8181
HAProxyConfigPath: hc.HAProxy,
82-
HAProxyLogWithThisApp: h.opts.LogAddress == "",
82+
HAProxyLogWithThisApp: h.opts.HAProxyLogAddress == "",
8383
DataplanePath: h.opts.DataplaneBin,
8484
DataplaneTransactionDir: hc.DataplaneTransactionDir,
8585
DataplaneSock: hc.DataplaneSock,

haproxy/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ type Options struct {
88
EnableIntentions bool
99
StatsListenAddr string
1010
StatsRegisterService bool
11-
LogRequests bool
12-
LogAddress string
11+
HAProxyLogRequests bool
12+
HAProxyLogAddress string
1313
}

haproxy/state.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ func (h *HAProxy) watch(sd *lib.Shutdown) error {
9696
newConsulCfg := nextState.Load().(consul.Config)
9797

9898
logAddress := h.haConfig.LogsSock
99-
if h.opts.LogAddress != "" {
100-
logAddress = h.opts.LogAddress
99+
if h.opts.HAProxyLogAddress != "" {
100+
logAddress = h.opts.HAProxyLogAddress
101101
}
102102

103103
newState, err := state.Generate(state.Options{
104104
EnableIntentions: h.opts.EnableIntentions,
105-
LogRequests: h.opts.LogRequests,
105+
LogRequests: h.opts.HAProxyLogRequests,
106106
LogAddress: logAddress,
107107
SPOEConfigPath: h.haConfig.SPOE,
108108
SPOESocket: h.haConfig.SPOESock,

main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func validateRequirements(dataplaneBin, haproxyBin string) error {
6363
}
6464

6565
// HAproxy doesn't exit immediately when you pass incorrect log address, so we try to do it on our own to fail fast
66-
func validateLogAddress(logAddress string) error {
67-
// possible values taken from https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-log
66+
func validateHaproxyLogAddress(logAddress string) error {
67+
// allowed values taken from https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-log
6868
fi, err := os.Stat(logAddress)
6969
if err != nil {
7070
match, err := regexp.Match(`(fd@<[0-9]+>|stdout|stderr)`, []byte(logAddress))
@@ -84,15 +84,15 @@ func validateLogAddress(logAddress string) error {
8484

8585
func main() {
8686
versionFlag := flag.Bool("version", false, "Show version and exit")
87-
logLevel := flag.String("log-level", "INFO", "Log level")
88-
logRequests := flag.Bool("log-requests", false, "Enable logging requests by Haproxy")
89-
logAddress := flag.String("log-address", "", "Syslog address for Haproxy logs (default: log to stderr with this app)")
9087
consulAddr := flag.String("http-addr", "127.0.0.1:8500", "Consul agent address")
9188
service := flag.String("sidecar-for", "", "The consul service id to proxy")
9289
serviceTag := flag.String("sidecar-for-tag", "", "The consul service id to proxy")
9390
haproxyBin := flag.String("haproxy", haproxy_cmd.DefaultHAProxyBin, "Haproxy binary path")
9491
dataplaneBin := flag.String("dataplane", haproxy_cmd.DefaultDataplaneBin, "Dataplane binary path")
9592
haproxyCfgBasePath := flag.String("haproxy-cfg-base-path", "/tmp", "Haproxy binary path")
93+
haproxyLogRequests := flag.Bool("haproxy-log-requests", false, "Enable logging requests by Haproxy")
94+
haproxyLogAddress := flag.String("haproxy-log-address", "", "Syslog address for Haproxy logs (default: log to stderr with this app)")
95+
logLevel := flag.String("log-level", "INFO", "Log level")
9696
statsListenAddr := flag.String("stats-addr", "", "Listen addr for stats server")
9797
statsServiceRegister := flag.Bool("stats-service-register", false, "Register a consul service for connect stats")
9898
enableIntentions := flag.Bool("enable-intentions", false, "Enable Connect intentions")
@@ -114,8 +114,8 @@ func main() {
114114
}
115115
log.SetLevel(ll)
116116

117-
if *logAddress != "" {
118-
if err := validateLogAddress(*logAddress); err != nil {
117+
if *haproxyLogAddress != "" {
118+
if err := validateHaproxyLogAddress(*haproxyLogAddress); err != nil {
119119
log.Fatal(err)
120120
}
121121
}
@@ -175,8 +175,8 @@ func main() {
175175
EnableIntentions: *enableIntentions,
176176
StatsListenAddr: *statsListenAddr,
177177
StatsRegisterService: *statsServiceRegister,
178-
LogRequests: *logRequests,
179-
LogAddress: *logAddress,
178+
HAProxyLogRequests: *haproxyLogRequests,
179+
HAProxyLogAddress: *haproxyLogAddress,
180180
})
181181
sd.Add(1)
182182
go func() {

0 commit comments

Comments
 (0)