Fix User-Agent header in requests made by Helm

Signed-off-by: Jakub Warczarek <jakub.warczarek@gmail.com>
pull/11226/head
Jakub Warczarek 3 years ago
parent 71ef5f477b
commit 2fa7b3d1b7

@ -33,6 +33,7 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"helm.sh/helm/v3/internal/version"
"helm.sh/helm/v3/pkg/helmpath" "helm.sh/helm/v3/pkg/helmpath"
) )
@ -230,5 +231,9 @@ func (s *EnvSettings) SetNamespace(namespace string) {
// RESTClientGetter gets the kubeconfig from EnvSettings // RESTClientGetter gets the kubeconfig from EnvSettings
func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter {
s.config.WrapConfigFn = func(c *rest.Config) *rest.Config {
c.UserAgent = version.GetUserAgent()
return c
}
return s.config return s.config
} }

@ -184,11 +184,11 @@ func (c *ChartDownloader) getOciURI(ref, version string, u *url.URL) (*url.URL,
// //
// A version is a SemVer string (1.2.3-beta.1+f334a6789). // A version is a SemVer string (1.2.3-beta.1+f334a6789).
// //
// - For fully qualified URLs, the version will be ignored (since URLs aren't versioned) // - For fully qualified URLs, the version will be ignored (since URLs aren't versioned)
// - For a chart reference // - For a chart reference
// * If version is non-empty, this will return the URL for that version // - If version is non-empty, this will return the URL for that version
// * If version is empty, this will return the URL for the latest version // - If version is empty, this will return the URL for the latest version
// * If no version can be found, an error is returned // - If no version can be found, an error is returned
func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, error) { func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, error) {
u, err := url.Parse(ref) u, err := url.Parse(ref)
if err != nil { if err != nil {

@ -120,7 +120,6 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) {
return "", err return "", err
} }
// TODO add user-agent
resp, err := r.Client.Get(indexURL, resp, err := r.Client.Get(indexURL,
getter.WithURL(r.Config.URL), getter.WithURL(r.Config.URL),
getter.WithInsecureSkipVerifyTLS(r.Config.InsecureSkipTLSverify), getter.WithInsecureSkipVerifyTLS(r.Config.InsecureSkipTLSverify),

Loading…
Cancel
Save