Skip to content

Commit

Permalink
adjust env overrides logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Cao committed Oct 18, 2018
1 parent 49aaaef commit 5a1ba3e
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions prog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,23 +459,28 @@ 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 {
Expand Down

0 comments on commit 5a1ba3e

Please sign in to comment.