allow to access oci repos without auth (#1711)

* allow to access oci repos without auth

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
kupnu4x 2021-03-09 09:23:36 +08:00 committed by GitHub
parent 14a83e7cbe
commit 8ed8a9eab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -385,10 +385,9 @@ func (st *HelmState) SyncRepos(helm RepoUpdater, shouldSkip map[string]bool) ([]
var err error
if repo.OCI {
username, password := gatherOCIUsernamePassword(repo.Name, repo.Username, repo.Password)
if username == "" || password == "" {
return nil, fmt.Errorf("username and password are required fields for logging in to OCI registries with helm")
if username != "" && password != "" {
err = helm.RegistryLogin(repo.URL, username, password)
}
err = helm.RegistryLogin(repo.URL, username, password)
} else {
err = helm.AddRepo(repo.Name, repo.URL, repo.CaFile, repo.CertFile, repo.KeyFile, repo.Username, repo.Password, repo.Managed)
}