Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Allow "v" prefix in orchestrator version and release (#2344)
Browse files Browse the repository at this point in the history
* fix quotation in etcd daemon args

* Revert "fix quotation in etcd daemon args"

This reverts commit 606bab4.

* trim v in orch ver / rel

* add unit tests
  • Loading branch information
Cecile Robert-Michon authored and jackfrancis committed Feb 27, 2018
1 parent 6ecbf45 commit f6eddde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/api/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/common/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
10 changes: 10 additions & 0 deletions pkg/api/vlabs/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f6eddde

Please sign in to comment.