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

Print proxy env vars when applying authz resources

This commit is contained in:
Sebastiaan van Steenis
2019-08-16 13:49:49 +02:00
committed by Alena Prokharchyk
parent a31f707eb5
commit 14827e2cdf
3 changed files with 24 additions and 20 deletions

View File

@@ -18,6 +18,8 @@ const (
WorkerThreads = 50
)
var proxyEnvVars = [3]string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
func StrToSemVer(version string) (*semver.Version, error) {
v, err := semver.NewVersion(strings.TrimPrefix(version, "v"))
if err != nil {
@@ -139,3 +141,23 @@ func GetEnvVar(key string) (string, string, bool) {
}
return "", "", false
}
func PrintProxyEnvVars() {
// Print proxy related environment variables
for _, proxyEnvVar := range proxyEnvVars {
var err error
// Lookup environment variable
if key, value, ok := 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 = 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)
}
}
}