Mage: Stop mutating release notes. (#11582)

* Mage: Implement static check recommendations.

* Mage: Stop mutating release notes.

---------

Co-authored-by: Marco Ebert <marco_ebert@icloud.com>
This commit is contained in:
k8s-infra-cherrypick-robot 2024-07-08 12:52:55 -07:00 committed by GitHub
parent 0300cb2214
commit 18735f0896
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 19 deletions

View file

@ -18,9 +18,7 @@ package steps
import (
"bytes"
"fmt"
"os"
"strings"
semver "github.com/blang/semver/v4"
"github.com/helm/helm/pkg/chartutil"
@ -104,18 +102,21 @@ func updateVersion(version string) {
utils.CheckIfError(err, "HELM Saving new Chart")
}
func updateChartReleaseNotes(releasesNotes []string) {
utils.Info("HELM Updating the Chart Release notes")
func updateChartReleaseNotes(releaseNotes []string) {
utils.Info("HELM Updating chart release notes")
chart, err := chartutil.LoadChartfile(HelmChartPath)
utils.CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath)
for i := range releasesNotes {
releasesNotes[i] = fmt.Sprintf("- %q", releasesNotes[i])
}
releaseNoteString := strings.Join(releasesNotes, "\n")
utils.Info("HELM Release note string %s", releaseNoteString)
chart.Annotations["artifacthub.io/changes"] = releaseNoteString
utils.CheckIfError(err, "HELM Failed to load chart manifest: %s", HelmChartPath)
releaseNotesBytes, err := yaml.Marshal(releaseNotes)
utils.CheckIfError(err, "HELM Failed to marshal release notes")
releaseNotesString := string(releaseNotesBytes)
utils.Info("HELM Chart release notes:\n%s", releaseNotesString)
chart.Annotations["artifacthub.io/changes"] = releaseNotesString
utils.Info("HELM Saving chart release notes")
err = chartutil.SaveChartfile(HelmChartPath, chart)
utils.CheckIfError(err, "HELM Saving updated release notes for Chart")
utils.CheckIfError(err, "HELM Failed to save chart manifest: %s", HelmChartPath)
}
// UpdateChartValue Updates the Helm ChartValue