@@ -81,27 +81,30 @@ func convertToSdkLocationPolicy(locationPolicy ManagedNodePoolLocationPolicy) co
8181
8282// ConvertToSdkAutoscaling converts node pool autoscaling config to a value that is used by GCP SDK.
8383func ConvertToSdkAutoscaling (autoscaling * NodePoolAutoScaling ) * containerpb.NodePoolAutoscaling {
84- if autoscaling == nil {
85- return nil
86- }
8784 sdkAutoscaling := containerpb.NodePoolAutoscaling {
88- Enabled : true , // enable autoscaling by default
89- }
90- // set fields
91- if autoscaling .MinCount != nil {
92- sdkAutoscaling .TotalMinNodeCount = * autoscaling .MinCount
93- }
94- if autoscaling .MaxCount != nil {
95- sdkAutoscaling .TotalMaxNodeCount = * autoscaling .MaxCount
96- }
97- if autoscaling .EnableAutoscaling != nil {
98- sdkAutoscaling .Enabled = * autoscaling .EnableAutoscaling
85+ Enabled : true , // enable autoscaling by default
86+ TotalMinNodeCount : 0 ,
87+ TotalMaxNodeCount : 1 ,
88+ LocationPolicy : convertToSdkLocationPolicy (ManagedNodePoolLocationPolicyBalanced ),
9989 }
100- if autoscaling .LocationPolicy != nil {
101- sdkAutoscaling .LocationPolicy = convertToSdkLocationPolicy (* autoscaling .LocationPolicy )
102- } else if sdkAutoscaling .Enabled {
103- // if location policy is not specified and autoscaling is enabled, default location policy to "any"
104- sdkAutoscaling .LocationPolicy = convertToSdkLocationPolicy (ManagedNodePoolLocationPolicyAny )
90+ if autoscaling != nil {
91+ // set fields
92+ if autoscaling .MinCount != nil {
93+ sdkAutoscaling .TotalMinNodeCount = * autoscaling .MinCount
94+ }
95+ if autoscaling .MaxCount != nil {
96+ sdkAutoscaling .TotalMaxNodeCount = * autoscaling .MaxCount
97+ }
98+ if autoscaling .LocationPolicy != nil {
99+ sdkAutoscaling .LocationPolicy = convertToSdkLocationPolicy (* autoscaling .LocationPolicy )
100+ }
101+ if autoscaling .EnableAutoscaling != nil {
102+ if ! * autoscaling .EnableAutoscaling {
103+ sdkAutoscaling = containerpb.NodePoolAutoscaling {
104+ Enabled : false ,
105+ }
106+ }
107+ }
105108 }
106109
107110 return & sdkAutoscaling
0 commit comments