1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-09 02:51:15 +00:00

Log proxy environment variables if set

This commit is contained in:
Sebastiaan van Steenis
2019-07-16 16:04:10 +02:00
committed by Alena Prokharchyk
parent d094535add
commit e923730388
2 changed files with 48 additions and 1 deletions

23
main.go
View File

@@ -4,15 +4,19 @@ import (
"github.com/rancher/rke/metadata"
"os"
"regexp"
"strings"
"github.com/mattn/go-colorable"
"github.com/rancher/rke/cmd"
"github.com/rancher/rke/util"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var VERSION = "v0.0.12-dev"
// VERSION gets overriden at build time using -X main.VERSION=$VERSION
var VERSION = "dev"
var released = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
var proxyEnvVars = [3]string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
func main() {
logrus.SetOutput(colorable.NewColorableStdout())
@@ -36,6 +40,23 @@ func mainErr() error {
return nil
}
logrus.Warnf("This is not an officially supported version (%s) of RKE. Please download the latest official release at https://github.com/rancher/rke/releases/latest", app.Version)
// Print proxy related environment variables
for _, proxyEnvVar := range proxyEnvVars {
var err error
// Lookup environment variable
if key, value, ok := util.GetEnvVar(proxyEnvVar); ok {
// If it can contain a password, strip it (HTTP_PROXY or HTTPS_PROXY)
if strings.HasPrefix(strings.ToUpper(proxyEnvVar), "HTTP") {
value, err = util.StripPasswordFromURL(value)
if err != nil {
// Don't error out of provisioning when parsing of environment variable fails
logrus.Warnf("Error parsing proxy environment variable %s", key)
continue
}
}
logrus.Infof("Using proxy environment variable %s with value [%s]", key, value)
}
}
return nil
}
app.Author = "Rancher Labs, Inc."