Clean-up the kube-version from Helm so that we can support GKE. (#2304)

This commit is contained in:
Alex Collins 2019-09-12 15:59:15 -07:00 committed by GitHub
parent 12b45116ed
commit 41b1b0a2d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 2 deletions

View file

@ -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{},
}

View file

@ -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" {

View file

@ -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, "+", "")
}

View file

@ -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+"))
}