diff --git a/util/helm/helm.go b/util/helm/helm.go index 9c8611c236..e5e3c5e9f9 100644 --- a/util/helm/helm.go +++ b/util/helm/helm.go @@ -16,6 +16,7 @@ import ( argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" "github.com/argoproj/argo-cd/util/config" "github.com/argoproj/argo-cd/util/kube" + "github.com/argoproj/argo-cd/util/text" ) // Helm provides wrapper functionality around the `helm` command. @@ -55,7 +56,7 @@ func (h *helm) Template(appName, namespace, kubeVersion string, opts *argoappv1. templateOpts := templateOpts{ name: appName, namespace: namespace, - kubeVersion: kubeVersion, + kubeVersion: text.SemVer(kubeVersion), set: map[string]string{}, setString: map[string]string{}, } diff --git a/util/helm/helm_test.go b/util/helm/helm_test.go index 705dcdeb78..eb91efede1 100644 --- a/util/helm/helm_test.go +++ b/util/helm/helm_test.go @@ -197,7 +197,7 @@ func TestHelmValues(t *testing.T) { slaveCount: 2 `, } - objs, err := h.Template("test", "", "", &opts) + objs, err := h.Template("test", "", "1.4+", &opts) assert.NoError(t, err) for _, obj := range objs { if obj.GetKind() == "Deployment" && obj.GetName() == "test-redis-slave" { diff --git a/util/text/text.go b/util/text/text.go index d8d803052a..bb0feebcc2 100644 --- a/util/text/text.go +++ b/util/text/text.go @@ -1,5 +1,7 @@ package text +import "strings" + // truncates messages to n characters func Trunc(message string, n int) string { if len(message) > n { @@ -7,3 +9,7 @@ func Trunc(message string, n int) string { } return message } + +func SemVer(s string) string { + return strings.ReplaceAll(s, "+", "") +} diff --git a/util/text/text_test.go b/util/text/text_test.go index a7a6ef6344..34d3648265 100644 --- a/util/text/text_test.go +++ b/util/text/text_test.go @@ -2,6 +2,8 @@ package text import ( "testing" + + "github.com/stretchr/testify/assert" ) func TestTrunc(t *testing.T) { @@ -26,3 +28,8 @@ func TestTrunc(t *testing.T) { }) } } + +func TestSemVer(t *testing.T) { + assert.Equal(t, "1.4", SemVer("1.4")) + assert.Equal(t, "1.4", SemVer("1.4+")) +}