From d9395bcc0668429a48cdfe8ff2389bb9d00f4e0e Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 25 Apr 2018 14:55:05 -0700 Subject: [PATCH] remove need for type reflection --- pkg/downloader/chart_downloader.go | 6 ++---- pkg/repo/chartrepo.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index 6861a8270..59b9d4d75 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -23,7 +23,6 @@ import ( "net/url" "os" "path/filepath" - "reflect" "strings" "k8s.io/helm/pkg/getter" @@ -243,9 +242,8 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, ge // If HttpGetter is used, this method sets the configured repository credentials on the HttpGetter. func (c *ChartDownloader) setCredentials(r *repo.ChartRepository) { - var t *getter.HttpGetter - if reflect.TypeOf(r.Client) == reflect.TypeOf(t) { - r.Client.(*getter.HttpGetter).SetCredentials(c.getRepoCredentials(r)) + if t, ok := r.Client.(*getter.HttpGetter); ok { + t.SetCredentials(c.getRepoCredentials(r)) } } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index ba1e6f4ff..438f66d7c 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -22,7 +22,6 @@ import ( "net/url" "os" "path/filepath" - "reflect" "strings" "github.com/ghodss/yaml" @@ -152,9 +151,8 @@ func (r *ChartRepository) DownloadIndexFile(cachePath string) error { // If HttpGetter is used, this method sets the configured repository credentials on the HttpGetter. func (r *ChartRepository) setCredentials() { - var t *getter.HttpGetter - if reflect.TypeOf(r.Client) == reflect.TypeOf(t) { - r.Client.(*getter.HttpGetter).SetCredentials(r.Config.Username, r.Config.Password) + if t, ok := r.Client.(*getter.HttpGetter); ok { + t.SetCredentials(r.Config.Username, r.Config.Password) } }