diff --git a/util/helm/client.go b/util/helm/client.go index 8fa3f6c0d24d8..8096b8009dbb4 100644 --- a/util/helm/client.go +++ b/util/helm/client.go @@ -425,8 +425,13 @@ func (c *nativeHelmChart) GetTags(chart string, noCache bool) (*TagsList, error) } ctx := context.Background() - err = repo.Tags(ctx, "", func(tagResult []string) error { - tags.Tags = append(tags.Tags, tagResult...) + err = repo.Tags(ctx, "", func(tagsResult []string) error { + for _, tag := range tagsResult { + // By convention: Change underscore (_) back to plus (+) to get valid SemVer + convertedTag := strings.ReplaceAll(tag, "_", "+") + tags.Tags = append(tags.Tags, convertedTag) + } + return nil }) diff --git a/util/helm/client_test.go b/util/helm/client_test.go index 67bb332a6007f..63b57b7fa5180 100644 --- a/util/helm/client_test.go +++ b/util/helm/client_test.go @@ -160,7 +160,14 @@ func TestGetTagsFromUrl(t *testing.T) { w.Header().Set("Link", fmt.Sprintf("; rel=next", r.Host, r.URL.Path)) responseTags.Tags = []string{"first"} } else { - responseTags.Tags = []string{"second"} + responseTags.Tags = []string{ + "second", + "2.8.0", + "2.8.0-prerelease", + "2.8.0_build", + "2.8.0-prerelease_build", + "2.8.0-prerelease.1_build.1234", + } } w.WriteHeader(http.StatusOK) err := json.NewEncoder(w).Encode(responseTags) @@ -173,6 +180,13 @@ func TestGetTagsFromUrl(t *testing.T) { tags, err := client.GetTags("mychart", true) assert.NoError(t, err) - assert.Equal(t, tags.Tags[0], "first") - assert.Equal(t, tags.Tags[1], "second") + assert.ElementsMatch(t, tags.Tags, []string{ + "first", + "second", + "2.8.0", + "2.8.0-prerelease", + "2.8.0+build", + "2.8.0-prerelease+build", + "2.8.0-prerelease.1+build.1234", + }) }