Skip to content

Commit

Permalink
Fix User-Agent header in requests made by Helm
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Warczarek <jakub.warczarek@gmail.com>
  • Loading branch information
programmer04 committed Jan 3, 2023
1 parent 71ef5f4 commit 2fa7b3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions pkg/cli/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/rest"

"helm.sh/helm/v3/internal/version"
"helm.sh/helm/v3/pkg/helmpath"
)

Expand Down Expand Up @@ -230,5 +231,9 @@ func (s *EnvSettings) SetNamespace(namespace string) {

// RESTClientGetter gets the kubeconfig from EnvSettings
func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter {
s.config.WrapConfigFn = func(c *rest.Config) *rest.Config {
c.UserAgent = version.GetUserAgent()
return c
}
return s.config
}
10 changes: 5 additions & 5 deletions pkg/downloader/chart_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
//
// - For fully qualified URLs, the version will be ignored (since URLs aren't versioned)
// - For a chart reference
// * 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 no version can be found, an error is returned
// - For fully qualified URLs, the version will be ignored (since URLs aren't versioned)
// - For a chart reference
// - 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 no version can be found, an error is returned
func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, error) {
u, err := url.Parse(ref)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/repo/chartrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) {
return "", err
}

// TODO add user-agent
resp, err := r.Client.Get(indexURL,
getter.WithURL(r.Config.URL),
getter.WithInsecureSkipVerifyTLS(r.Config.InsecureSkipTLSverify),
Expand Down

0 comments on commit 2fa7b3d

Please sign in to comment.