This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nil check for managed cluster and its properties object (#3197)
* adding nil check for managed cluster and its properties object * adding check for update scenario * adding merge code and UTs * correcting UTs * correcting lint errors
- Loading branch information
Showing
5 changed files
with
239 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package v20170831 | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// Merge existing ManagedCluster attribute into mc | ||
func (mc *ManagedCluster) Merge(emc *ManagedCluster) error { | ||
|
||
// Merge properties.dnsPrefix | ||
if emc.Properties.DNSPrefix == "" { | ||
return fmt.Errorf("existing ManagedCluster expect properties.dnsPrefix not to be empty") | ||
} | ||
|
||
if mc.Properties.DNSPrefix == "" { | ||
mc.Properties.DNSPrefix = emc.Properties.DNSPrefix | ||
} else if mc.Properties.DNSPrefix != emc.Properties.DNSPrefix { | ||
return fmt.Errorf("change dnsPrefix from %s to %s is not supported", | ||
emc.Properties.DNSPrefix, | ||
mc.Properties.DNSPrefix) | ||
} | ||
// Merge Properties.AgentPoolProfiles | ||
if mc.Properties.AgentPoolProfiles == nil { | ||
mc.Properties.AgentPoolProfiles = emc.Properties.AgentPoolProfiles | ||
} | ||
// Merge Properties.LinuxProfile | ||
if mc.Properties.LinuxProfile == nil { | ||
mc.Properties.LinuxProfile = emc.Properties.LinuxProfile | ||
} | ||
// Merge Properties.WindowsProfile | ||
if mc.Properties.WindowsProfile == nil { | ||
mc.Properties.WindowsProfile = emc.Properties.WindowsProfile | ||
} | ||
// Merge Properties.ServicePrincipalProfile | ||
if mc.Properties.ServicePrincipalProfile == nil { | ||
mc.Properties.ServicePrincipalProfile = emc.Properties.ServicePrincipalProfile | ||
} | ||
// Merge Properties.KubernetesVersion | ||
if mc.Properties.KubernetesVersion == "" { | ||
mc.Properties.KubernetesVersion = emc.Properties.KubernetesVersion | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters