From 27535517b181908a9b9e6cca2afd3f575ca2c761 Mon Sep 17 00:00:00 2001 From: "Sahdev P. Zala" Date: Wed, 9 Oct 2019 18:22:25 -0400 Subject: [PATCH] pkg: handle version env variable Version flag is meant for displaying version and it's a boolean. It's for an internal use, and we may not want users to set it in the environment. Fixes # 11210 --- etcdmain/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/etcdmain/config.go b/etcdmain/config.go index 33d1fd06a..3eaa9babb 100644 --- a/etcdmain/config.go +++ b/etcdmain/config.go @@ -316,6 +316,13 @@ func (cfg *config) parse(arguments []string) error { } func (cfg *config) configFromCmdLine() error { + verKey := "ETCD_VERSION" + if verVal := os.Getenv(verKey); verVal != "" { + // unset to avoid any possible side-effect. + os.Unsetenv(verKey) + plog.Warningf("cannot set special environment variable %s=%s", verKey, verVal) + } + err := flags.SetFlagsFromEnv("ETCD", cfg.cf.flagSet) if err != nil { return err