From 5c26a9850b72f9af84f05a3d664dbacc03ecf832 Mon Sep 17 00:00:00 2001 From: Payal Godhani Date: Tue, 28 Jan 2025 16:02:19 -0800 Subject: [PATCH] Renaming the function to address the feedback -e Signed-off-by: Payal Godhani --- pkg/action/install.go | 2 +- pkg/action/pull.go | 2 +- pkg/downloader/manager.go | 2 +- pkg/repo/chartrepo.go | 4 ++-- pkg/repo/chartrepo_test.go | 16 ++++++++-------- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 61d352a50..17c453a28 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -789,7 +789,7 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( dl.Verify = downloader.VerifyAlways } if c.RepoURL != "" { - chartURL, err := repo.FindChartInAuthRepoURL(c.RepoURL, c.Username, c.Password, name, version, + chartURL, err := repo.FindChartRepoURL(c.RepoURL, c.Username, c.Password, name, version, c.CertFile, c.KeyFile, c.CaFile, c.InsecureSkipTLSverify, c.PassCredentialsAll, getter.All(settings)) if err != nil { return "", err diff --git a/pkg/action/pull.go b/pkg/action/pull.go index 82298c533..cd7eba927 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -117,7 +117,7 @@ func (p *Pull) Run(chartRef string) (string, error) { } if p.RepoURL != "" { - chartURL, err := repo.FindChartInAuthRepoURL(p.RepoURL, p.Username, p.Password, chartRef, p.Version, + chartURL, err := repo.FindChartRepoURL(p.RepoURL, p.Username, p.Password, chartRef, p.Version, p.CertFile, p.KeyFile, p.CaFile, p.InsecureSkipTLSverify, p.PassCredentialsAll, getter.All(p.Settings)) if err != nil { return out.String(), err diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 23bfadaef..be3c8e6e0 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -742,7 +742,7 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]* return } } - url, err = repo.FindChartInAuthRepoURL(repoURL, "", "", name, version, certFile, keyFile, caFile, false, false, m.Getters) + url, err = repo.FindChartRepoURL(repoURL, "", "", name, version, certFile, keyFile, caFile, false, false, m.Getters) if err == nil { return url, username, password, false, false, "", "", "", err } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 5545295ef..d415a74ff 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -196,9 +196,9 @@ func (r *ChartRepository) generateIndex() error { return nil } -// FindChartInAuthRepoURL finds chart in chart repository pointed by repoURL +// FindChartRepoURL finds chart in chart repository pointed by repoURL // without adding repo to repositories, and supports authentication, TLS settings, and optional passing of credentials to other domains. -func FindChartInAuthRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, insecureSkipTLSverify, passCredentialsAll bool, getters getter.Providers) (string, error) { +func FindChartRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, insecureSkipTLSverify, passCredentialsAll bool, getters getter.Providers) (string, error) { // Download and write the index file to a temporary location buf := make([]byte, 20) rand.Read(buf) diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index 73219552d..1dd8f50a9 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -297,7 +297,7 @@ func TestChartInAuthRepoURL(t *testing.T) { } defer srv.Close() - chartURL, err := FindChartInAuthRepoURL(srv.URL, "", "", "nginx", "", "", "", "", true, false, getter.All(&cli.EnvSettings{})) + chartURL, err := FindChartRepoURL(srv.URL, "", "", "nginx", "", "", "", "", true, false, getter.All(&cli.EnvSettings{})) if err != nil { t.Fatalf("%v", err) } @@ -306,7 +306,7 @@ func TestChartInAuthRepoURL(t *testing.T) { } // If the insecureSkipTLSVerify is false, it will return an error that contains "x509: certificate signed by unknown authority". - _, err = FindChartInAuthRepoURL(srv.URL, "", "", "nginx", "0.1.0", "", "", "", false, false, getter.All(&cli.EnvSettings{})) + _, err = FindChartRepoURL(srv.URL, "", "", "nginx", "0.1.0", "", "", "", false, false, getter.All(&cli.EnvSettings{})) // Go communicates with the platform and different platforms return different messages. Go itself tests darwin // differently for its message. On newer versions of Darwin the message includes the "Acme Co" portion while older // versions of Darwin do not. As there are people developing Helm using both old and new versions of Darwin we test @@ -327,7 +327,7 @@ func TestFindChartInRepoURL(t *testing.T) { } defer srv.Close() - chartURL, err := FindChartInAuthRepoURL(srv.URL, "", "", "nginx", "", "", "", "", false, false, getter.All(&cli.EnvSettings{})) + chartURL, err := FindChartRepoURL(srv.URL, "", "", "nginx", "", "", "", "", false, false, getter.All(&cli.EnvSettings{})) if err != nil { t.Fatalf("%v", err) } @@ -335,7 +335,7 @@ func TestFindChartInRepoURL(t *testing.T) { t.Errorf("%s is not the valid URL", chartURL) } - chartURL, err = FindChartInAuthRepoURL(srv.URL, "", "", "nginx", "0.1.0", "", "", "", false, false, getter.All(&cli.EnvSettings{})) + chartURL, err = FindChartRepoURL(srv.URL, "", "", "nginx", "0.1.0", "", "", "", false, false, getter.All(&cli.EnvSettings{})) if err != nil { t.Errorf("%s", err) } @@ -350,7 +350,7 @@ func TestErrorFindChartInRepoURL(t *testing.T) { RepositoryCache: t.TempDir(), }) - if _, err := FindChartInAuthRepoURL("http://someserver/something", "", "", "nginx", "", "", "", "", false, false, g); err == nil { + if _, err := FindChartRepoURL("http://someserver/something", "", "", "nginx", "", "", "", "", false, false, g); err == nil { t.Errorf("Expected error for bad chart URL, but did not get any errors") } else if !strings.Contains(err.Error(), `looks like "http://someserver/something" is not a valid chart repository or cannot be reached`) { t.Errorf("Expected error for bad chart URL, but got a different error (%v)", err) @@ -362,19 +362,19 @@ func TestErrorFindChartInRepoURL(t *testing.T) { } defer srv.Close() - if _, err = FindChartInAuthRepoURL(srv.URL, "", "", "nginx1", "", "", "", "", false, false, g); err == nil { + if _, err = FindChartRepoURL(srv.URL, "", "", "nginx1", "", "", "", "", false, false, g); err == nil { t.Errorf("Expected error for chart not found, but did not get any errors") } else if err.Error() != `chart "nginx1" not found in `+srv.URL+` repository` { t.Errorf("Expected error for chart not found, but got a different error (%v)", err) } - if _, err = FindChartInAuthRepoURL(srv.URL, "", "", "nginx1", "0.1.0", "", "", "", false, false, g); err == nil { + if _, err = FindChartRepoURL(srv.URL, "", "", "nginx1", "0.1.0", "", "", "", false, false, g); err == nil { t.Errorf("Expected error for chart not found, but did not get any errors") } else if err.Error() != `chart "nginx1" version "0.1.0" not found in `+srv.URL+` repository` { t.Errorf("Expected error for chart not found, but got a different error (%v)", err) } - if _, err = FindChartInAuthRepoURL(srv.URL, "", "", "chartWithNoURL", "", "", "", "", false, false, g); err == nil { + if _, err = FindChartRepoURL(srv.URL, "", "", "chartWithNoURL", "", "", "", "", false, false, g); err == nil { t.Errorf("Expected error for no chart URLs available, but did not get any errors") } else if err.Error() != `chart "chartWithNoURL" has no downloadable URLs` { t.Errorf("Expected error for chart not found, but got a different error (%v)", err)