Skip to content

Commit

Permalink
Merge pull request #92 from jenkins-x-plugins/prevent_upgrade
Browse files Browse the repository at this point in the history
fix: ignore upgrade of charts that lack version
  • Loading branch information
jenkins-x-bot authored Jul 15, 2024
2 parents a5d2541 + 52c160c commit 681d6e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/pr/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 10 additions & 6 deletions pkg/cmd/pr/version_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 681d6e7

Please sign in to comment.