Skip to content

Commit

Permalink
fix: Avoid casting nil to boolean when not set in customizeDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs committed Dec 2, 2024
1 parent d58d2c8 commit 3fa50f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/service/eks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,11 @@ func validateAutoModeCustsomizeDiff(_ context.Context, d *schema.ResourceDiff, _
kubernetesNetworkConfig := expandKubernetesNetworkConfigRequest(d.Get("kubernetes_network_config").([]interface{}))
storageConfig := expandStorageConfigRequest(d.Get("storage_config").([]interface{}))

if aws.ToBool(computeConfig.Enabled) != aws.ToBool(kubernetesNetworkConfig.ElasticLoadBalancing.Enabled) || aws.ToBool(computeConfig.Enabled) != aws.ToBool(storageConfig.BlockStorage.Enabled) {
computeConfigEnabled := computeConfig != nil && computeConfig.Enabled != nil && aws.ToBool(computeConfig.Enabled)
kubernetesNetworkConfigEnabled := kubernetesNetworkConfig != nil && kubernetesNetworkConfig.ElasticLoadBalancing != nil && kubernetesNetworkConfig.ElasticLoadBalancing.Enabled != nil && aws.ToBool(kubernetesNetworkConfig.ElasticLoadBalancing.Enabled)
storageConfigEnabled := storageConfig != nil && storageConfig.BlockStorage != nil && storageConfig.BlockStorage.Enabled != nil && aws.ToBool(storageConfig.BlockStorage.Enabled)

if computeConfigEnabled != kubernetesNetworkConfigEnabled || computeConfigEnabled != storageConfigEnabled {
return errors.New("compute_config.enabled, kubernetes_networking_config.elastic_load_balancing.enabled, and storage_config.block_storage.enabled must all be set to either true or false")
}
}
Expand Down

0 comments on commit 3fa50f3

Please sign in to comment.