From 7f62e1aac2b5d9860b59662ac733be652eba0919 Mon Sep 17 00:00:00 2001 From: Nathan Schmidt Date: Thu, 27 May 2021 09:59:27 +1000 Subject: [PATCH] Remove verbose logging when updating chart repo index This commit removes logs lines resulting from loading the index of a chart repo containing many charts that don't adhere to semver. Motivation behind this change is simple, there is little to no impact from these log lines, and in most cases no action that the user could reasonably expect to make. In the authors case, this change reduces the output of `helm repo up` from +100MB to <1KB. Signed-off-by: Nathan Schmidt --- pkg/repo/chartrepo.go | 2 +- pkg/repo/index.go | 8 +++----- pkg/repo/index_test.go | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) 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") } }