ref(downloader): remove username/password fields from ChartDownloader

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
pull/5918/head
Matthew Fisher 6 years ago
parent c35dbb7aab
commit 393eab2f39
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -621,8 +621,6 @@ func (c *ChartPathOptions) LocateChart(name string, settings cli.EnvSettings) (s
Out: os.Stdout, Out: os.Stdout,
Keyring: c.Keyring, Keyring: c.Keyring,
Getters: getter.All(settings), Getters: getter.All(settings),
Username: c.Username,
Password: c.Password,
} }
if c.Verify { if c.Verify {
dl.Verify = downloader.VerifyAlways dl.Verify = downloader.VerifyAlways

@ -62,8 +62,6 @@ func (p *Pull) Run(chartRef string) (string, error) {
Keyring: p.Keyring, Keyring: p.Keyring,
Verify: downloader.VerifyNever, Verify: downloader.VerifyNever,
Getters: getter.All(p.Settings), Getters: getter.All(p.Settings),
Username: p.Username,
Password: p.Password,
} }
if p.Verify { if p.Verify {

@ -68,10 +68,6 @@ type ChartDownloader struct {
HelmHome helmpath.Home HelmHome helmpath.Home
// Getter collection for the operation // Getter collection for the operation
Getters getter.Providers Getters getter.Providers
// Chart repository username
Username string
// Chart repository password
Password string
} }
// DownloadTo retrieves a chart. Depending on the settings, it may also download a provenance file. // DownloadTo retrieves a chart. Depending on the settings, it may also download a provenance file.
@ -255,15 +251,9 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, ge
// then the repository's configured credentials are returned. // then the repository's configured credentials are returned.
// Else, this ChartDownloader's credentials are returned. // Else, this ChartDownloader's credentials are returned.
func (c *ChartDownloader) getRepoCredentials(r *repo.ChartRepository) (username, password string) { func (c *ChartDownloader) getRepoCredentials(r *repo.ChartRepository) (username, password string) {
username = c.Username
password = c.Password
if r != nil && r.Config != nil { if r != nil && r.Config != nil {
if username == "" { username = r.Config.Username
username = r.Config.Username password = r.Config.Password
}
if password == "" {
password = r.Config.Password
}
} }
return return
} }

@ -231,7 +231,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
// Any failure to resolve/download a chart should fail: // Any failure to resolve/download a chart should fail:
// https://github.com/helm/helm/issues/1439 // https://github.com/helm/helm/issues/1439
churl, username, password, err := findChartURL(dep.Name, dep.Version, dep.Repository, repos) churl, err := findChartURL(dep.Name, dep.Version, dep.Repository, repos)
if err != nil { if err != nil {
saveError = errors.Wrapf(err, "could not find %s", churl) saveError = errors.Wrapf(err, "could not find %s", churl)
break break
@ -243,8 +243,6 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
Keyring: m.Keyring, Keyring: m.Keyring,
HelmHome: m.HelmHome, HelmHome: m.HelmHome,
Getters: m.Getters, Getters: m.Getters,
Username: username,
Password: password,
} }
if _, _, err := dl.DownloadTo(churl, "", destPath); err != nil { if _, _, err := dl.DownloadTo(churl, "", destPath); err != nil {
@ -467,7 +465,7 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
// repoURL is the repository to search // repoURL is the repository to search
// //
// If it finds a URL that is "relative", it will prepend the repoURL. // If it finds a URL that is "relative", it will prepend the repoURL.
func findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRepository) (url, username, password string, err error) { func findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRepository) (url string, err error) {
for _, cr := range repos { for _, cr := range repos {
if urlutil.Equal(repoURL, cr.Config.URL) { if urlutil.Equal(repoURL, cr.Config.URL) {
var entry repo.ChartVersions var entry repo.ChartVersions
@ -484,8 +482,6 @@ func findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRep
if err != nil { if err != nil {
return return
} }
username = cr.Config.Username
password = cr.Config.Password
return return
} }
} }

@ -77,19 +77,13 @@ func TestFindChartURL(t *testing.T) {
version := "0.1.0" version := "0.1.0"
repoURL := "http://example.com/charts" repoURL := "http://example.com/charts"
churl, username, password, err := findChartURL(name, version, repoURL, repos) churl, err := findChartURL(name, version, repoURL, repos)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if churl != "https://kubernetes-charts.storage.googleapis.com/alpine-0.1.0.tgz" { if churl != "https://kubernetes-charts.storage.googleapis.com/alpine-0.1.0.tgz" {
t.Errorf("Unexpected URL %q", churl) t.Errorf("Unexpected URL %q", churl)
} }
if username != "" {
t.Errorf("Unexpected username %q", username)
}
if password != "" {
t.Errorf("Unexpected password %q", password)
}
} }
func TestGetRepoNames(t *testing.T) { func TestGetRepoNames(t *testing.T) {

Loading…
Cancel
Save