diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 09b94fd42..6b1713120 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -139,7 +139,7 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) { return "", err } - indexFile, err := loadIndex(index, r.Config.URL) + indexFile, err := loadIndex(index) if err != nil { return "", err } diff --git a/pkg/repo/index.go b/pkg/repo/index.go index e86b17349..c746fcab1 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -106,7 +106,7 @@ func LoadIndexFile(path string) (*IndexFile, error) { if err != nil { return nil, err } - i, err := loadIndex(b, path) + i, err := loadIndex(b) if err != nil { return nil, errors.Wrapf(err, "error loading %s", path) } @@ -322,21 +322,19 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) { // loadIndex loads an index file and does minimal validity checking. // -// The source parameter is only used for logging. // This will fail if API Version is not set (ErrNoAPIVersion) or if the unmarshal fails. -func loadIndex(data []byte, source string) (*IndexFile, error) { +func loadIndex(data []byte) (*IndexFile, error) { i := &IndexFile{} if err := yaml.UnmarshalStrict(data, i); err != nil { return i, err } - for name, cvs := range i.Entries { + for _, cvs := range i.Entries { for idx := len(cvs) - 1; idx >= 0; idx-- { if cvs[idx].APIVersion == "" { cvs[idx].APIVersion = chart.APIVersionV1 } if err := cvs[idx].Validate(); err != nil { - log.Printf("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err) cvs = append(cvs[:idx], cvs[idx+1:]...) } } diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index 47f3c6b2e..9c372c050 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -147,7 +147,7 @@ func TestLoadIndex(t *testing.T) { // TestLoadIndex_Duplicates is a regression to make sure that we don't non-deterministically allow duplicate packages. func TestLoadIndex_Duplicates(t *testing.T) { - if _, err := loadIndex([]byte(indexWithDuplicates), "indexWithDuplicates"); err == nil { + if _, err := loadIndex([]byte(indexWithDuplicates)); err == nil { t.Errorf("Expected an error when duplicate entries are present") } }