Fix issue with relative URLs

Signed-off-by: MichaelMorris <michael.morris@est.tech>
pull/13342/head
MichaelMorris 1 year ago
parent 99009c7be8
commit 4f378b7d2d

@ -771,7 +771,7 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*
urlsKey := repoURL + name + version
if _, ok := urls[urlsKey]; ok {
url = urls[urlsKey]
url, err = repo.ResolveReferenceURL(repoURL, urls[urlsKey])
} else {
url, err = repo.FindChartInRepoURL(repoURL, name, m.Getters, repo.WithChartVersion(version), repo.WithClientTLS(certFile, keyFile, caFile))
}

@ -143,6 +143,68 @@ func TestFindChartURL(t *testing.T) {
}
}
func TestFindChartURLBasedOnUrlMap(t *testing.T) {
var b bytes.Buffer
m := &Manager{
Out: &b,
RepositoryConfig: repoConfig,
RepositoryCache: repoCache,
}
repos := make(map[string]*repo.ChartRepository)
name := "alpine"
version := "0.1.0"
repoURL := "http://example.com/charts"
urlMap := make(map[string]string)
urlKey := repoURL + name + version
urlMap[urlKey] = "https://charts.helm.sh/stable/alpine-0.1.0.tgzFromMap"
churl, username, password, insecureSkipTLSVerify, passcredentialsall, _, _, _, err := m.findChartURL(name, version, repoURL, repos, urlMap)
if err != nil {
t.Fatal(err)
}
if churl != "https://charts.helm.sh/stable/alpine-0.1.0.tgzFromMap" {
t.Errorf("Unexpected URL %q", churl)
}
if username != "" {
t.Errorf("Unexpected username %q", username)
}
if password != "" {
t.Errorf("Unexpected password %q", password)
}
if passcredentialsall != false {
t.Errorf("Unexpected passcredentialsall %t", passcredentialsall)
}
if insecureSkipTLSVerify {
t.Errorf("Unexpected insecureSkipTLSVerify %t", insecureSkipTLSVerify)
}
urlMap[urlKey] = "alpine-0.1.0.tgz"
churl, username, password, insecureSkipTLSVerify, passcredentialsall, _, _, _, err = m.findChartURL(name, version, repoURL, repos, urlMap)
if err != nil {
t.Fatal(err)
}
if churl != "http://example.com/charts/alpine-0.1.0.tgz" {
t.Errorf("Unexpected URL %q", churl)
}
if username != "" {
t.Errorf("Unexpected username %q", username)
}
if password != "" {
t.Errorf("Unexpected password %q", password)
}
if passcredentialsall != false {
t.Errorf("Unexpected passcredentialsall %t", passcredentialsall)
}
if insecureSkipTLSVerify {
t.Errorf("Unexpected insecureSkipTLSVerify %t", insecureSkipTLSVerify)
}
}
func TestGetRepoNames(t *testing.T) {
b := bytes.NewBuffer(nil)
m := &Manager{

Loading…
Cancel
Save