Skip to content

Commit 8fa9860

Browse files
committed
pkg/types: set Azure machine pool defaults from defaultMachinePlatform
This commit updates default value handling when loading the install config to set values in machine pools based on the defaultMachinePlatform. By populating the values directly in the install config, we can avoid repetitive checks throughout the codebase to ensure the default machine platform is applied to the relevant machine pool.
1 parent 6e4a27d commit 8fa9860

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/types/azure/defaults/platform.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ func SetPlatformDefaults(p *azure.Platform) {
2424
}
2525
}
2626

27+
// Apply sets values from the default machine platform to the machinepool.
28+
func Apply(defaultMachinePlatform, machinePool *azure.MachinePool) {
29+
// Construct a temporary machine pool so we can set the
30+
// defaults first, without overwriting the pool-sepcific values,
31+
// which have precedence.
32+
tempMP := &azure.MachinePool{}
33+
tempMP.Set(defaultMachinePlatform)
34+
tempMP.Set(machinePool)
35+
machinePool.Set(tempMP)
36+
}
37+
2738
// getInstanceClass returns the instance "class" we should use for a given region.
2839
func getInstanceClass(region string) string {
2940
if class, ok := defaultMachineClass[region]; ok {

pkg/types/defaults/machinepools.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package defaults
22

33
import (
44
"github.com/openshift/installer/pkg/types"
5+
"github.com/openshift/installer/pkg/types/azure"
6+
azuredefaults "github.com/openshift/installer/pkg/types/azure/defaults"
57
"github.com/openshift/installer/pkg/types/gcp"
68
gcpdefaults "github.com/openshift/installer/pkg/types/gcp/defaults"
79
"github.com/openshift/installer/pkg/version"
@@ -24,6 +26,11 @@ func SetMachinePoolDefaults(p *types.MachinePool, platform *types.Platform) {
2426
}
2527

2628
switch platform.Name() {
29+
case azure.Name:
30+
if p.Platform.Azure == nil && platform.Azure.DefaultMachinePlatform != nil {
31+
p.Platform.Azure = &azure.MachinePool{}
32+
}
33+
azuredefaults.Apply(platform.Azure.DefaultMachinePlatform, p.Platform.Azure)
2734
case gcp.Name:
2835
gcpdefaults.SetMachinePoolDefaults(platform, p.Platform.GCP)
2936
default:

0 commit comments

Comments
 (0)