From 867db89303dc05e7db7441eb65524beaba9b70c4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 6 May 2018 08:54:36 -0700 Subject: [PATCH] command/connect/proxy: set proxy ID from env var if set --- command/connect/proxy/proxy.go | 6 ++++++ connect/proxy/proxy.go | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/command/connect/proxy/proxy.go b/command/connect/proxy/proxy.go index 362e704598..a4558d21f3 100644 --- a/command/connect/proxy/proxy.go +++ b/command/connect/proxy/proxy.go @@ -7,7 +7,9 @@ import ( "log" "net/http" _ "net/http/pprof" // Expose pprof if configured + "os" + proxyAgent "github.com/hashicorp/consul/agent/proxy" "github.com/hashicorp/consul/command/flags" proxyImpl "github.com/hashicorp/consul/connect/proxy" @@ -74,6 +76,10 @@ func (c *cmd) Run(args []string) int { return 1 } + // Load the proxy ID and token from env vars if they're set + if c.proxyID == "" { + c.proxyID = os.Getenv(proxyAgent.EnvProxyId) + } // Setup the log outputs logConfig := &logger.Config{ LogLevel: c.logLevel, diff --git a/connect/proxy/proxy.go b/connect/proxy/proxy.go index 717d45ae6d..e3db982fe3 100644 --- a/connect/proxy/proxy.go +++ b/connect/proxy/proxy.go @@ -68,7 +68,6 @@ func New(client *api.Client, proxyID string, logger *log.Logger) (*Proxy, error) // Serve the proxy instance until a fatal error occurs or proxy is closed. func (p *Proxy) Serve() error { - var cfg *Config // Watch for config changes (initial setup happens on first "change")