From 5c55e5585d423eee18bbf4e94f8c88ea7dda44c2 Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Wed, 3 Jun 2020 12:27:12 +0200 Subject: [PATCH] Add haproxy prefix where applicable --- haproxy/haproxy.go | 6 +++--- haproxy/options.go | 4 ++-- haproxy/state.go | 6 +++--- main.go | 18 +++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/haproxy/haproxy.go b/haproxy/haproxy.go index d42e24f..a34d258 100644 --- a/haproxy/haproxy.go +++ b/haproxy/haproxy.go @@ -60,13 +60,13 @@ func (h *HAProxy) start(sd *lib.Shutdown) error { } h.haConfig = hc - if h.opts.LogAddress == "" { + if h.opts.HAProxyLogAddress == "" { err := h.startLogger() if err != nil { return err } } else { - log.Infof("not starting built-in syslog - using %s as syslog address", h.opts.LogAddress) + log.Infof("not starting built-in syslog - using %s as syslog address", h.opts.HAProxyLogAddress) } if h.opts.EnableIntentions { @@ -79,7 +79,7 @@ func (h *HAProxy) start(sd *lib.Shutdown) error { dpc, err := haproxy_cmd.Start(sd, haproxy_cmd.Config{ HAProxyPath: h.opts.HAProxyBin, HAProxyConfigPath: hc.HAProxy, - HAProxyLogWithThisApp: h.opts.LogAddress == "", + HAProxyLogWithThisApp: h.opts.HAProxyLogAddress == "", DataplanePath: h.opts.DataplaneBin, DataplaneTransactionDir: hc.DataplaneTransactionDir, DataplaneSock: hc.DataplaneSock, diff --git a/haproxy/options.go b/haproxy/options.go index 43fc5f5..88741bb 100644 --- a/haproxy/options.go +++ b/haproxy/options.go @@ -8,6 +8,6 @@ type Options struct { EnableIntentions bool StatsListenAddr string StatsRegisterService bool - LogRequests bool - LogAddress string + HAProxyLogRequests bool + HAProxyLogAddress string } diff --git a/haproxy/state.go b/haproxy/state.go index a5b24de..3fc476b 100644 --- a/haproxy/state.go +++ b/haproxy/state.go @@ -96,13 +96,13 @@ func (h *HAProxy) watch(sd *lib.Shutdown) error { newConsulCfg := nextState.Load().(consul.Config) logAddress := h.haConfig.LogsSock - if h.opts.LogAddress != "" { - logAddress = h.opts.LogAddress + if h.opts.HAProxyLogAddress != "" { + logAddress = h.opts.HAProxyLogAddress } newState, err := state.Generate(state.Options{ EnableIntentions: h.opts.EnableIntentions, - LogRequests: h.opts.LogRequests, + LogRequests: h.opts.HAProxyLogRequests, LogAddress: logAddress, SPOEConfigPath: h.haConfig.SPOE, SPOESocket: h.haConfig.SPOESock, diff --git a/main.go b/main.go index a73bbf5..fb4f92d 100644 --- a/main.go +++ b/main.go @@ -63,8 +63,8 @@ func validateRequirements(dataplaneBin, haproxyBin string) error { } // HAproxy doesn't exit immediately when you pass incorrect log address, so we try to do it on our own to fail fast -func validateLogAddress(logAddress string) error { - // possible values taken from https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-log +func validateHaproxyLogAddress(logAddress string) error { + // allowed values taken from https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-log fi, err := os.Stat(logAddress) if err != nil { match, err := regexp.Match(`(fd@<[0-9]+>|stdout|stderr)`, []byte(logAddress)) @@ -84,15 +84,15 @@ func validateLogAddress(logAddress string) error { func main() { versionFlag := flag.Bool("version", false, "Show version and exit") - logLevel := flag.String("log-level", "INFO", "Log level") - logRequests := flag.Bool("log-requests", false, "Enable logging requests by Haproxy") - logAddress := flag.String("log-address", "", "Syslog address for Haproxy logs (default: log to stderr with this app)") consulAddr := flag.String("http-addr", "127.0.0.1:8500", "Consul agent address") service := flag.String("sidecar-for", "", "The consul service id to proxy") serviceTag := flag.String("sidecar-for-tag", "", "The consul service id to proxy") haproxyBin := flag.String("haproxy", haproxy_cmd.DefaultHAProxyBin, "Haproxy binary path") dataplaneBin := flag.String("dataplane", haproxy_cmd.DefaultDataplaneBin, "Dataplane binary path") haproxyCfgBasePath := flag.String("haproxy-cfg-base-path", "/tmp", "Haproxy binary path") + haproxyLogRequests := flag.Bool("haproxy-log-requests", false, "Enable logging requests by Haproxy") + haproxyLogAddress := flag.String("haproxy-log-address", "", "Syslog address for Haproxy logs (default: log to stderr with this app)") + logLevel := flag.String("log-level", "INFO", "Log level") statsListenAddr := flag.String("stats-addr", "", "Listen addr for stats server") statsServiceRegister := flag.Bool("stats-service-register", false, "Register a consul service for connect stats") enableIntentions := flag.Bool("enable-intentions", false, "Enable Connect intentions") @@ -114,8 +114,8 @@ func main() { } log.SetLevel(ll) - if *logAddress != "" { - if err := validateLogAddress(*logAddress); err != nil { + if *haproxyLogAddress != "" { + if err := validateHaproxyLogAddress(*haproxyLogAddress); err != nil { log.Fatal(err) } } @@ -175,8 +175,8 @@ func main() { EnableIntentions: *enableIntentions, StatsListenAddr: *statsListenAddr, StatsRegisterService: *statsServiceRegister, - LogRequests: *logRequests, - LogAddress: *logAddress, + HAProxyLogRequests: *haproxyLogRequests, + HAProxyLogAddress: *haproxyLogAddress, }) sd.Add(1) go func() {