diff --git a/pkg/api/common/helper.go b/pkg/api/common/helper.go index ef7d9d5a32..4e9580db14 100644 --- a/pkg/api/common/helper.go +++ b/pkg/api/common/helper.go @@ -98,6 +98,9 @@ func GetValidPatchVersion(orchType, orchVer string) string { // RationalizeReleaseAndVersion return a version when it can be rationalized from the input, otherwise "" func RationalizeReleaseAndVersion(orchType, orchRel, orchVer string) (version string) { + // ignore "v" prefix in orchestrator version and release: "v1.8.0" is equivalent to "1.8.0", "v1.9" is equivalent to "1.9" + orchVer = strings.TrimPrefix(orchVer, "v") + orchRel = strings.TrimPrefix(orchRel, "v") supportedVersions, defaultVersion := GetSupportedVersions(orchType) if supportedVersions == nil { return "" diff --git a/pkg/api/common/helper_test.go b/pkg/api/common/helper_test.go index 15a46fda58..688ca83fda 100644 --- a/pkg/api/common/helper_test.go +++ b/pkg/api/common/helper_test.go @@ -80,4 +80,13 @@ func Test_RationalizeReleaseAndVersion(t *testing.T) { t.Errorf("It is not 1.5.8") } + version = RationalizeReleaseAndVersion(Kubernetes, "", "v1.8.8") + if version != KubernetesVersion1Dot8Dot8 { + t.Errorf("It is not Kubernetes version %s", KubernetesVersion1Dot8Dot8) + } + + version = RationalizeReleaseAndVersion(Kubernetes, "v1.9", "") + if version != KubernetesVersion1Dot9Dot3 { + t.Errorf("It is not Kubernetes version %s", KubernetesVersion1Dot9Dot3) + } } diff --git a/pkg/api/vlabs/validate_test.go b/pkg/api/vlabs/validate_test.go index d336385c69..f964df9ecb 100644 --- a/pkg/api/vlabs/validate_test.go +++ b/pkg/api/vlabs/validate_test.go @@ -63,6 +63,16 @@ func Test_OrchestratorProfile_Validate(t *testing.T) { if err := o.Validate(true); err != nil { t.Errorf("should not have failed on old patch version during update valdiation") } + + o = &OrchestratorProfile{ + OrchestratorType: "Kubernetes", + OrchestratorVersion: "v1.9.0", + } + + if err := o.Validate(false); err != nil { + t.Errorf("should not have failed on version with v prefix") + } + } func Test_KubernetesConfig_Validate(t *testing.T) {