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

Commit

Permalink
pass in isUpdate bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon committed Dec 5, 2018
1 parent f938ba1 commit c410923
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 4 additions & 2 deletions pkg/api/apiloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ func (a *Apiloader) LoadContainerService(
if e := containerService.Properties.Validate(isUpdate); validate && e != nil {
return nil, e
}
unversioned := ConvertV20170701ContainerService(containerService)
if curOrchVersion != "" {
unversioned := ConvertV20170701ContainerService(containerService, isUpdate)
if curOrchVersion != "" &&
(containerService.Properties.OrchestratorProfile == nil ||
containerService.Properties.OrchestratorProfile.OrchestratorVersion == "") {
unversioned.Properties.OrchestratorProfile.OrchestratorVersion = curOrchVersion
}
return unversioned, nil
Expand Down
12 changes: 6 additions & 6 deletions pkg/api/convertertoapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func ConvertV20170131ContainerService(v20170131 *v20170131.ContainerService) *Co
}

// ConvertV20170701ContainerService converts a v20170701 ContainerService to an unversioned ContainerService
func ConvertV20170701ContainerService(v20170701 *v20170701.ContainerService) *ContainerService {
func ConvertV20170701ContainerService(v20170701 *v20170701.ContainerService, isUpdate bool) *ContainerService {
c := &ContainerService{}
c.ID = v20170701.ID
c.Location = helpers.NormalizeAzureRegion(v20170701.Location)
Expand All @@ -94,7 +94,7 @@ func ConvertV20170701ContainerService(v20170701 *v20170701.ContainerService) *Co
}
c.Type = v20170701.Type
c.Properties = &Properties{}
convertV20170701Properties(v20170701.Properties, c.Properties)
convertV20170701Properties(v20170701.Properties, c.Properties, isUpdate)
return c
}

Expand Down Expand Up @@ -300,12 +300,12 @@ func convertV20170131Properties(v20170131 *v20170131.Properties, api *Properties
}
}

func convertV20170701Properties(v20170701 *v20170701.Properties, api *Properties) {
func convertV20170701Properties(v20170701 *v20170701.Properties, api *Properties, isUpdate bool) {
api.ProvisioningState = ProvisioningState(v20170701.ProvisioningState)

if v20170701.OrchestratorProfile != nil {
api.OrchestratorProfile = &OrchestratorProfile{}
convertV20170701OrchestratorProfile(v20170701.OrchestratorProfile, api.OrchestratorProfile, v20170701.HasWindows())
convertV20170701OrchestratorProfile(v20170701.OrchestratorProfile, api.OrchestratorProfile, isUpdate, v20170701.HasWindows())
}
if v20170701.MasterProfile != nil {
api.MasterProfile = &MasterProfile{}
Expand Down Expand Up @@ -564,7 +564,7 @@ func convertV20170131OrchestratorProfile(v20170131 *v20170131.OrchestratorProfil
}
}

func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProfile, api *OrchestratorProfile, hasWindows bool) {
func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProfile, api *OrchestratorProfile, isUpdate, hasWindows bool) {
if v20170701cs.OrchestratorType == v20170701.DockerCE {
api.OrchestratorType = SwarmMode
} else {
Expand All @@ -573,7 +573,7 @@ func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProf

switch api.OrchestratorType {
case Kubernetes:
api.OrchestratorVersion = common.GetSupportedKubernetesVersion(v20170701cs.OrchestratorVersion, hasWindows)
api.OrchestratorVersion = common.RationalizeReleaseAndVersion(Kubernetes, "", v20170701cs.OrchestratorVersion, isUpdate, hasWindows)
case DCOS:
switch v20170701cs.OrchestratorVersion {
case common.DCOSVersion1Dot10Dot0, common.DCOSVersion1Dot9Dot0, common.DCOSVersion1Dot8Dot8:
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/convertertoapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestOrchestratorVersion(t *testing.T) {
},
},
}
cs := ConvertV20170701ContainerService(v20170701cs)
cs := ConvertV20170701ContainerService(v20170701cs, false)
if cs.Properties.OrchestratorProfile.OrchestratorVersion != common.GetDefaultKubernetesVersion(false) {
t.Fatalf("incorrect OrchestratorVersion '%s'", cs.Properties.OrchestratorProfile.OrchestratorVersion)
}
Expand All @@ -97,12 +97,12 @@ func TestOrchestratorVersion(t *testing.T) {
Properties: &v20170701.Properties{
OrchestratorProfile: &v20170701.OrchestratorProfile{
OrchestratorType: v20170701.Kubernetes,
OrchestratorVersion: "1.7.15",
OrchestratorVersion: "1.7.14",
},
},
}
cs = ConvertV20170701ContainerService(v20170701cs)
if cs.Properties.OrchestratorProfile.OrchestratorVersion != "1.7.15" {
cs = ConvertV20170701ContainerService(v20170701cs, true)
if cs.Properties.OrchestratorProfile.OrchestratorVersion != "1.7.14" {
t.Fatalf("incorrect OrchestratorVersion '%s'", cs.Properties.OrchestratorProfile.OrchestratorVersion)
}
// test vlabs
Expand Down

0 comments on commit c410923

Please sign in to comment.