Enable setting proxyurl in kubeconfig via kubectl config (#105566)

* Enable setting proxyurl in kubeconfig via kubectl config

This PR enables setting `proxy-url` in kubeconfig via kubectl config.

* Add godoc for proxy-url unit tests

Kubernetes-commit: afdde383210294c3da573decc44b5ce55cffcb94
This commit is contained in:
Arda Güçlü 2021-12-20 21:12:56 +03:00 committed by Kubernetes Publisher
parent d7ed9408c8
commit a6257fdee4
3 changed files with 8 additions and 4 deletions

4
go.mod
View File

@ -30,7 +30,7 @@ require (
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/protobuf v1.27.1
k8s.io/api v0.0.0-20211215212153-038a002081e5
k8s.io/api v0.0.0-20211217212405-236866c4c265
k8s.io/apimachinery v0.0.0-20211215211714-e7b02e651498
k8s.io/klog/v2 v2.30.0
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65
@ -40,6 +40,6 @@ require (
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20211215212153-038a002081e5
k8s.io/api => k8s.io/api v0.0.0-20211217212405-236866c4c265
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20211215211714-e7b02e651498
)

4
go.sum
View File

@ -610,8 +610,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20211215212153-038a002081e5 h1:uZaBzUjpiQ1X1YPtzRA3I5+kqx7zYkD1uUZ7Ea7hc0k=
k8s.io/api v0.0.0-20211215212153-038a002081e5/go.mod h1:kH5z5h8lnbGVPS6+JweP/T3Hd4aXG2QxsxPT9RmDg3Q=
k8s.io/api v0.0.0-20211217212405-236866c4c265 h1:4yrbMQUZVVX2JHcpJuCaxQwhXB1QuUW7BmK/PKKax2o=
k8s.io/api v0.0.0-20211217212405-236866c4c265/go.mod h1:kH5z5h8lnbGVPS6+JweP/T3Hd4aXG2QxsxPT9RmDg3Q=
k8s.io/apimachinery v0.0.0-20211215211714-e7b02e651498 h1:Gx+CxWyEfYzIYDyNgZuGHeszYhsZdIYF0v7/DGO83Bc=
k8s.io/apimachinery v0.0.0-20211215211714-e7b02e651498/go.mod h1:YpCy0BWvwSGZKMwmvPxCsfFJfl6vAwQdfVnPOJoUT2E=
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=

View File

@ -73,6 +73,7 @@ type ClusterOverrideFlags struct {
CertificateAuthority FlagInfo
InsecureSkipTLSVerify FlagInfo
TLSServerName FlagInfo
ProxyURL FlagInfo
}
// FlagInfo contains information about how to register a flag. This struct is useful if you want to provide a way for an extender to
@ -160,6 +161,7 @@ const (
FlagUsername = "username"
FlagPassword = "password"
FlagTimeout = "request-timeout"
FlagProxyURL = "proxy-url"
)
// RecommendedConfigOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing
@ -195,6 +197,7 @@ func RecommendedClusterOverrideFlags(prefix string) ClusterOverrideFlags {
CertificateAuthority: FlagInfo{prefix + FlagCAFile, "", "", "Path to a cert file for the certificate authority"},
InsecureSkipTLSVerify: FlagInfo{prefix + FlagInsecure, "", "false", "If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure"},
TLSServerName: FlagInfo{prefix + FlagTLSServerName, "", "", "If provided, this name will be used to validate server certificate. If this is not provided, hostname used to contact the server is used."},
ProxyURL: FlagInfo{prefix + FlagProxyURL, "", "", "If provided, this URL will be used to connect via proxy"},
}
}
@ -234,6 +237,7 @@ func BindClusterFlags(clusterInfo *clientcmdapi.Cluster, flags *pflag.FlagSet, f
flagNames.CertificateAuthority.BindStringFlag(flags, &clusterInfo.CertificateAuthority)
flagNames.InsecureSkipTLSVerify.BindBoolFlag(flags, &clusterInfo.InsecureSkipTLSVerify)
flagNames.TLSServerName.BindStringFlag(flags, &clusterInfo.TLSServerName)
flagNames.ProxyURL.BindStringFlag(flags, &clusterInfo.ProxyURL)
}
// BindFlags is a convenience method to bind the specified flags to their associated variables