mirror of
https://github.com/rancher/rke.git
synced 2025-05-02 05:23:32 +00:00
Print proxy env vars when applying authz resources
This commit is contained in:
parent
a31f707eb5
commit
14827e2cdf
@ -310,6 +310,8 @@ func ApplyAuthzResources(ctx context.Context, rkeConfig v3.RancherKubernetesEngi
|
|||||||
if len(kubeCluster.ControlPlaneHosts) == 0 {
|
if len(kubeCluster.ControlPlaneHosts) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// Print proxy environment variables as we are directly contacting the cluster
|
||||||
|
util.PrintProxyEnvVars()
|
||||||
if err := authz.ApplyJobDeployerServiceAccount(ctx, kubeCluster.LocalKubeConfigPath, kubeCluster.K8sWrapTransport); err != nil {
|
if err := authz.ApplyJobDeployerServiceAccount(ctx, kubeCluster.LocalKubeConfigPath, kubeCluster.K8sWrapTransport); err != nil {
|
||||||
return fmt.Errorf("Failed to apply the ServiceAccount needed for job execution: %v", err)
|
return fmt.Errorf("Failed to apply the ServiceAccount needed for job execution: %v", err)
|
||||||
}
|
}
|
||||||
|
20
main.go
20
main.go
@ -5,11 +5,9 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
"github.com/rancher/rke/cmd"
|
"github.com/rancher/rke/cmd"
|
||||||
"github.com/rancher/rke/util"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -17,7 +15,6 @@ import (
|
|||||||
// VERSION gets overridden at build time using -X main.VERSION=$VERSION
|
// VERSION gets overridden at build time using -X main.VERSION=$VERSION
|
||||||
var VERSION = "dev"
|
var VERSION = "dev"
|
||||||
var released = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
|
var released = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
|
||||||
var proxyEnvVars = [3]string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logrus.SetOutput(colorable.NewColorableStdout())
|
logrus.SetOutput(colorable.NewColorableStdout())
|
||||||
@ -44,23 +41,6 @@ func mainErr() error {
|
|||||||
return nil
|
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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
app.Author = "Rancher Labs, Inc."
|
app.Author = "Rancher Labs, Inc."
|
||||||
|
22
util/util.go
22
util/util.go
@ -18,6 +18,8 @@ const (
|
|||||||
WorkerThreads = 50
|
WorkerThreads = 50
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var proxyEnvVars = [3]string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
|
||||||
|
|
||||||
func StrToSemVer(version string) (*semver.Version, error) {
|
func StrToSemVer(version string) (*semver.Version, error) {
|
||||||
v, err := semver.NewVersion(strings.TrimPrefix(version, "v"))
|
v, err := semver.NewVersion(strings.TrimPrefix(version, "v"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -139,3 +141,23 @@ func GetEnvVar(key string) (string, string, bool) {
|
|||||||
}
|
}
|
||||||
return "", "", false
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user