@@ -192,25 +192,24 @@ func isAutoModeCluster(r *resource) bool {
192192 return false
193193 }
194194
195- // If ComputeConfig is not specified, this is not an Auto Mode cluster
196- if r .ko .Spec .ComputeConfig == nil {
195+ // Check if all three Auto Mode configurations are present
196+ hasComputeConfig := r .ko .Spec .ComputeConfig != nil
197+ hasStorageConfig := r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil
198+ hasELBConfig := r .ko .Spec .KubernetesNetworkConfig != nil && r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing != nil
199+
200+ // All three must be present for this to be considered an Auto Mode cluster
201+ if ! hasComputeConfig || ! hasStorageConfig || ! hasELBConfig {
197202 return false
198203 }
199204
200205 // Check compute configuration
201206 computeEnabled := r .ko .Spec .ComputeConfig .Enabled != nil && * r .ko .Spec .ComputeConfig .Enabled
202207
203208 // Check storage configuration
204- storageEnabled := false
205- if r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil {
206- storageEnabled = r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
207- }
209+ storageEnabled := r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
208210
209211 // Check elastic load balancing configuration
210- elbEnabled := false
211- if r .ko .Spec .KubernetesNetworkConfig != nil && r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing != nil {
212- elbEnabled = r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled != nil && * r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled
213- }
212+ elbEnabled := r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled != nil && * r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled
214213
215214 // Auto Mode requires all three capabilities to have the same state (all true or all false)
216215 // If they are all true, Auto Mode is enabled
@@ -222,25 +221,31 @@ func isAutoModeCluster(r *resource) bool {
222221// validateAutoModeConfig validates that Auto Mode configuration is consistent.
223222// Returns an error if the configuration is invalid (partial enablement).
224223func validateAutoModeConfig (r * resource ) error {
225- if r == nil || r .ko == nil || r . ko . Spec . ComputeConfig == nil {
224+ if r == nil || r .ko == nil {
226225 return nil // Not an Auto Mode configuration
227226 }
228227
229- // Check compute configuration
230- computeEnabled := r .ko .Spec .ComputeConfig .Enabled != nil && * r .ko .Spec .ComputeConfig .Enabled
228+ // Check if any Auto Mode configuration is present
229+ hasComputeConfig := r .ko .Spec .ComputeConfig != nil
230+ hasStorageConfig := r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil
231+ hasELBConfig := r .ko .Spec .KubernetesNetworkConfig != nil && r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing != nil
231232
232- // Check storage configuration
233- storageEnabled := false
234- if r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil {
235- storageEnabled = r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
233+ // If no Auto Mode configuration is present, it's valid (not an Auto Mode cluster)
234+ if ! hasComputeConfig && ! hasStorageConfig && ! hasELBConfig {
235+ return nil
236236 }
237237
238- // Check elastic load balancing configuration
239- elbEnabled := false
240- if r . ko . Spec . KubernetesNetworkConfig != nil && r . ko . Spec . KubernetesNetworkConfig . ElasticLoadBalancing != nil {
241- elbEnabled = r . ko . Spec . KubernetesNetworkConfig . ElasticLoadBalancing . Enabled != nil && * r . ko . Spec . KubernetesNetworkConfig . ElasticLoadBalancing . Enabled
238+ // If any Auto Mode configuration is present, ALL must be present
239+ if ! hasComputeConfig || ! hasStorageConfig || ! hasELBConfig {
240+ return fmt . Errorf ( "invalid Auto Mode configuration: when configuring Auto Mode, all three capabilities must be specified (compute=%v, storage=%v, elb=%v)" ,
241+ hasComputeConfig , hasStorageConfig , hasELBConfig )
242242 }
243243
244+ // Check that all configurations have the same enabled state
245+ computeEnabled := r .ko .Spec .ComputeConfig .Enabled != nil && * r .ko .Spec .ComputeConfig .Enabled
246+ storageEnabled := r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
247+ elbEnabled := r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled != nil && * r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled
248+
244249 // All three must be in the same state
245250 if computeEnabled == storageEnabled && storageEnabled == elbEnabled {
246251 return nil // Valid configuration
0 commit comments