Skip to content

Commit 961194d

Browse files
bb-Ricardomattfarina
authored andcommitted
improves handling of Helm index with broken helm chart versions #13176
Signed-off-by: [email protected] <[email protected]> (cherry picked from commit 154b477)
1 parent f6be62b commit 961194d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/repo/index.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ func loadIndex(data []byte, source string) (*IndexFile, error) {
353353
return i, err
354354
}
355355

356+
if i.APIVersion == "" {
357+
return i, ErrNoAPIVersion
358+
}
359+
356360
for name, cvs := range i.Entries {
357361
for idx := len(cvs) - 1; idx >= 0; idx-- {
358362
if cvs[idx] == nil {
@@ -371,11 +375,10 @@ func loadIndex(data []byte, source string) (*IndexFile, error) {
371375
cvs = append(cvs[:idx], cvs[idx+1:]...)
372376
}
373377
}
378+
// adjust slice to only contain a set of valid versions
379+
i.Entries[name] = cvs
374380
}
375381
i.SortEntries()
376-
if i.APIVersion == "" {
377-
return i, ErrNoAPIVersion
378-
}
379382
return i, nil
380383
}
381384

0 commit comments

Comments
 (0)