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"
"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))
}
}

@ -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)
}
}

Loading…
Cancel
Save