Skip to content

Commit

Permalink
Add nil check on bq destination array contents (#3774) (#2296)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 22, 2020
1 parent 1a37ef6 commit 939245b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/3774.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
`container`: Fixed a crash in `google_container_cluster` when `""` was specified for `resource_usage_export_config.bigquery_destination.dataset_id`.
```
5 changes: 3 additions & 2 deletions google-beta/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2941,8 +2941,9 @@ func expandResourceUsageExportConfig(configured interface{}) *containerBeta.Reso
ForceSendFields: []string{"EnableNetworkEgressMetering"},
}
if _, ok := resourceUsageConfig["bigquery_destination"]; ok {
if len(resourceUsageConfig["bigquery_destination"].([]interface{})) > 0 {
bigqueryDestination := resourceUsageConfig["bigquery_destination"].([]interface{})[0].(map[string]interface{})
destinationArr := resourceUsageConfig["bigquery_destination"].([]interface{})
if len(destinationArr) > 0 && destinationArr[0] != nil {
bigqueryDestination := destinationArr[0].(map[string]interface{})
if _, ok := bigqueryDestination["dataset_id"]; ok {
result.BigqueryDestination = &containerBeta.BigQueryDestination{
DatasetId: bigqueryDestination["dataset_id"].(string),
Expand Down

0 comments on commit 939245b

Please sign in to comment.