From 52c160c537bc22a7263bb43a2030fe115378a2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Svantesson?= Date: Fri, 14 Jun 2024 10:18:10 +0200 Subject: [PATCH] fix: ignore upgrade of charts that lack version typically that would be because a switch to another chart is specified also doing spelling fix --- pkg/cmd/pr/pr.go | 2 +- pkg/cmd/pr/version_stream.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/cmd/pr/pr.go b/pkg/cmd/pr/pr.go index 6e1edd7..7f6da7d 100644 --- a/pkg/cmd/pr/pr.go +++ b/pkg/cmd/pr/pr.go @@ -81,7 +81,7 @@ func NewCmdPullRequest() (*cobra.Command, *Options) { cmd.Flags().StringVarP(&o.Version, "version", "", "", "the version number to promote. If not specified uses $VERSION or the version file") cmd.Flags().StringVarP(&o.VersionFile, "version-file", "", "", "the file to load the version from if not specified directly or via a $VERSION environment variable. Defaults to VERSION in the current dir") cmd.Flags().StringVarP(&o.Application, "app", "a", "", "the Application to promote. Used for informational purposes") - cmd.Flags().StringVarP(&o.AddChangelog, "add-changelog", "", "", "a file to take a changelog from to add to the pullr equest body. Typically a file generated by jx changelog.") + cmd.Flags().StringVarP(&o.AddChangelog, "add-changelog", "", "", "a file to take a changelog from to add to the pull request body. Typically a file generated by jx changelog.") cmd.Flags().StringVarP(&o.ChangelogSeparator, "changelog-separator", "", os.Getenv("CHANGELOG_SEPARATOR"), "the separator to use between commit message and changelog in the pull request body. Default to ----- or if set the CHANGELOG_SEPARATOR environment variable") cmd.Flags().StringVar(&o.CommitTitle, "pull-request-title", "", "the PR title") cmd.Flags().StringVar(&o.CommitMessage, "pull-request-body", "", "the PR body") diff --git a/pkg/cmd/pr/version_stream.go b/pkg/cmd/pr/version_stream.go index a3e21df..597bf80 100644 --- a/pkg/cmd/pr/version_stream.go +++ b/pkg/cmd/pr/version_stream.go @@ -113,6 +113,16 @@ func (o *Options) applyVersionStreamCharts(dir string, vs *v1alpha1.VersionStrea for _, n := range ci.Names { name := scm.Join(repoPrefix, n) + sv, err := versionstream.LoadStableVersion(dir, versionstream.VersionKind(kindStr), name) + if err != nil { + return fmt.Errorf("failed to load stable version for %s: %w", name, err) + } + + oldVersion := sv.Version + if oldVersion == "" { + log.Logger().Debugf("no upgrade is done of chart %s since no version is set", name) + continue + } info, err := o.Helmer.SearchCharts(name, true) if err != nil { return fmt.Errorf("failed to search for chart %s: %w", name, err) @@ -128,12 +138,6 @@ func (o *Options) applyVersionStreamCharts(dir string, vs *v1alpha1.VersionStrea continue } - sv, err := versionstream.LoadStableVersion(dir, versionstream.VersionKind(kindStr), name) - if err != nil { - return fmt.Errorf("failed to load stable version for %s: %w", name, err) - } - - oldVersion := sv.Version if oldVersion != version { _, err := versionstream.UpdateStableVersion(dir, kindStr, name, version) if err != nil {