remove need for type reflection

pull/3968/head
Matthew Fisher 7 years ago
parent c2fa72ebcd
commit d9395bcc06
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -23,7 +23,6 @@ import (
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
"reflect"
"strings" "strings"
"k8s.io/helm/pkg/getter" "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. // If HttpGetter is used, this method sets the configured repository credentials on the HttpGetter.
func (c *ChartDownloader) setCredentials(r *repo.ChartRepository) { func (c *ChartDownloader) setCredentials(r *repo.ChartRepository) {
var t *getter.HttpGetter if t, ok := r.Client.(*getter.HttpGetter); ok {
if reflect.TypeOf(r.Client) == reflect.TypeOf(t) { t.SetCredentials(c.getRepoCredentials(r))
r.Client.(*getter.HttpGetter).SetCredentials(c.getRepoCredentials(r))
} }
} }

@ -22,7 +22,6 @@ import (
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
"reflect"
"strings" "strings"
"github.com/ghodss/yaml" "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. // If HttpGetter is used, this method sets the configured repository credentials on the HttpGetter.
func (r *ChartRepository) setCredentials() { func (r *ChartRepository) setCredentials() {
var t *getter.HttpGetter if t, ok := r.Client.(*getter.HttpGetter); ok {
if reflect.TypeOf(r.Client) == reflect.TypeOf(t) { t.SetCredentials(r.Config.Username, r.Config.Password)
r.Client.(*getter.HttpGetter).SetCredentials(r.Config.Username, r.Config.Password)
} }
} }

Loading…
Cancel
Save