Fix dependency build when use repository with basic authentication

pull/9867/head
王炜 4 years ago
parent fa558f7843
commit 11f783a784

@ -720,6 +720,10 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*
return
}
}
if urlUsername, urlPassword, ok := getBasicAuth(repoURL); ok {
username = urlUsername
password = urlPassword
}
url, err = repo.FindChartInRepoURL(repoURL, name, version, certFile, keyFile, caFile, m.Getters)
if err == nil {
return url, username, password, false, false, "", "", "", err
@ -787,6 +791,18 @@ func normalizeURL(baseURL, urlOrPath string) (string, error) {
return u2.String(), nil
}
func getBasicAuth(baseURL string) (string, string, bool) {
u, err := url.Parse(baseURL)
if err != nil {
return "", "", false
}
if _, ok := u.User.Password(); !ok {
return "", "", false
}
password, _ := u.User.Password()
return u.User.Username(), password, true
}
// loadChartRepositories reads the repositories.yaml, and then builds a map of
// ChartRepositories.
//

Loading…
Cancel
Save