Skip to content

Commit 939245b

Browse files
Add nil check on bq destination array contents (#3774) (#2296)
Signed-off-by: Modular Magician <[email protected]>
1 parent 1a37ef6 commit 939245b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changelog/3774.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
`container`: Fixed a crash in `google_container_cluster` when `""` was specified for `resource_usage_export_config.bigquery_destination.dataset_id`.
3+
```

google-beta/resource_container_cluster.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,8 +2941,9 @@ func expandResourceUsageExportConfig(configured interface{}) *containerBeta.Reso
29412941
ForceSendFields: []string{"EnableNetworkEgressMetering"},
29422942
}
29432943
if _, ok := resourceUsageConfig["bigquery_destination"]; ok {
2944-
if len(resourceUsageConfig["bigquery_destination"].([]interface{})) > 0 {
2945-
bigqueryDestination := resourceUsageConfig["bigquery_destination"].([]interface{})[0].(map[string]interface{})
2944+
destinationArr := resourceUsageConfig["bigquery_destination"].([]interface{})
2945+
if len(destinationArr) > 0 && destinationArr[0] != nil {
2946+
bigqueryDestination := destinationArr[0].(map[string]interface{})
29462947
if _, ok := bigqueryDestination["dataset_id"]; ok {
29472948
result.BigqueryDestination = &containerBeta.BigQueryDestination{
29482949
DatasetId: bigqueryDestination["dataset_id"].(string),

0 commit comments

Comments
 (0)