Skip to content

Commit

Permalink
remove need for type reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fisher committed Apr 25, 2018
1 parent c2fa72e commit d9395bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions pkg/downloader/chart_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"net/url"
"os"
"path/filepath"
"reflect"
"strings"

"k8s.io/helm/pkg/getter"
Expand Down Expand Up @@ -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))
}
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/repo/chartrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"net/url"
"os"
"path/filepath"
"reflect"
"strings"

"github.com/ghodss/yaml"
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit d9395bc

Please sign in to comment.