From 06be566ef176d5d2dc21567d464086a891858456 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 31 Mar 2021 13:05:02 +0300 Subject: [PATCH] fix(repo): make IndexFile.Has() match exact version Change Has() function to check against the exact version (as described in the docstring comment) instead of falling back to the semver constraints business. Fixes index merge in cases where version numbers are similar enough (but not identical), causing previous entries to be inadvertently overwritten. Signed-off-by: Markus Lehtonen --- pkg/repo/index.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index e86b17349..b9341c56d 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -154,8 +154,12 @@ func (i IndexFile) Add(md *chart.Metadata, filename, baseURL, digest string) { // Has returns true if the index has an entry for a chart with the given name and exact version. func (i IndexFile) Has(name, version string) bool { - _, err := i.Get(name, version) - return err == nil + for _, ver := range i.Entries[name] { + if version == ver.Version { + return true + } + } + return false } // SortEntries sorts the entries by version in descending order.