From 12f64701a27d1f0e9f469560391cb58307181b46 Mon Sep 17 00:00:00 2001 From: Yu Cao Date: Wed, 17 Oct 2018 21:44:07 -0400 Subject: [PATCH] adjust env overrides logic --- prog/main.go | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/prog/main.go b/prog/main.go index dcb1e9d7a..39ee6aae8 100644 --- a/prog/main.go +++ b/prog/main.go @@ -459,23 +459,29 @@ func main() { flags.probe.kubernetesNodeName = os.Getenv("KUBERNETES_NODENAME") } - if strings.ToLower(os.Getenv("ENABLE_BASIC_AUTH")) == "false" { - log.Infof("Basic authentication enabled.") + if strings.ToLower(os.Getenv("ENABLE_BASIC_AUTH")) == "true" { + flags.probe.basicAuth = true + flags.app.basicAuth = true + } else if strings.ToLower(os.Getenv("ENABLE_BASIC_AUTH")) == "false" { flags.probe.basicAuth = false flags.app.basicAuth = false + } + username := os.Getenv("BASIC_AUTH_USERNAME") + if username != "" { + flags.probe.username = username + flags.app.username = username + } + password := os.Getenv("BASIC_AUTH_PASSWORD") + if password != "" { + flags.probe.password = password + flags.app.password = password + } + + if flags.basicAuth { + log.Infof("Basic authentication enabled") } else { - log.Infof("Basic authentication enabled.") - username := os.Getenv("BASIC_AUTH_USERNAME") - if username != "" { - flags.probe.username = username - flags.app.username = username - } - password := os.Getenv("BASIC_AUTH_PASSWORD") - if password != "" { - flags.probe.password = password - flags.app.password = password - } + log.Infof("Basic authentication disabled") } if flags.dryRun {