command/connect/proxy: set proxy ID from env var if set

This commit is contained in:
Mitchell Hashimoto 2018-05-06 08:54:36 -07:00
parent 6e386ba6be
commit 867db89303
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 6 additions and 1 deletions

View File

@ -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,

View File

@ -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")