From 311ab9b22ce6f2445f63c8c80ce20151e6d8060f Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Tue, 7 Jan 2025 05:10:22 +0530 Subject: [PATCH] adding fix for helm versioning issue Signed-off-by: Vishwanath Hiremath --- go.mod | 1 + go.sum | 2 ++ pkg/cli/helm/cluster.go | 9 ++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b8fddc62c4..d4fade5476 100644 --- a/go.mod +++ b/go.mod @@ -102,6 +102,7 @@ require ( cloud.google.com/go/iam v1.1.8 // indirect cloud.google.com/go/storage v1.42.0 // indirect dario.cat/mergo v1.0.1 // indirect + github.com/Masterminds/semver v1.5.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/hcsshim v0.12.4 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect diff --git a/go.sum b/go.sum index cf2283073b..759911d7b4 100644 --- a/go.sum +++ b/go.sum @@ -243,6 +243,8 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= diff --git a/pkg/cli/helm/cluster.go b/pkg/cli/helm/cluster.go index c4e07a872f..b64a825740 100644 --- a/pkg/cli/helm/cluster.go +++ b/pkg/cli/helm/cluster.go @@ -26,6 +26,7 @@ import ( "helm.sh/helm/v3/pkg/storage/driver" "k8s.io/cli-runtime/pkg/genericclioptions" + "github.com/Masterminds/semver" "github.com/radius-project/radius/pkg/version" ) @@ -51,7 +52,13 @@ func NewDefaultClusterOptions() ClusterOptions { // If this is an edge build, we'll use the latest available. chartVersion := version.ChartVersion() if !version.IsEdgeChannel() { - chartVersion = fmt.Sprintf("~%s", version.ChartVersion()) + // When the chart version is the final release, we should use the ~ operator to ensure we fetch the latest patch version. + // For the pre release or dev builds, we should use the exact version. + ver, _ := semver.NewVersion(chartVersion) + preRelease := ver.Prerelease() + if preRelease == "" { + chartVersion = fmt.Sprintf("~%s", version.ChartVersion()) + } } return ClusterOptions{