Skip to content

Commit 3e86dde

Browse files
modular-magicianshuyama1
authored andcommitted
potential fix for a crash in google_storage_bucket when providers upgrade to 4.42.0 (#6758) (#12922)
Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent dbb48be commit 3e86dde

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changelog/6758.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
storage: fixed a crash in `google_storage_bucket` when upgrading provider to version `4.42.0` with `lifecycle_rule.condition.age` unset
3+
```

google/resource_storage_bucket.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,6 @@ func flattenBucketLifecycleRuleAction(action *storage.BucketLifecycleRuleAction)
10801080

10811081
func flattenBucketLifecycleRuleCondition(condition *storage.BucketLifecycleRuleCondition) map[string]interface{} {
10821082
ruleCondition := map[string]interface{}{
1083-
"age": int(*condition.Age),
10841083
"created_before": condition.CreatedBefore,
10851084
"matches_storage_class": convertStringArrToInterface(condition.MatchesStorageClass),
10861085
"num_newer_versions": int(condition.NumNewerVersions),
@@ -1091,6 +1090,9 @@ func flattenBucketLifecycleRuleCondition(condition *storage.BucketLifecycleRuleC
10911090
"matches_prefix": convertStringArrToInterface(condition.MatchesPrefix),
10921091
"matches_suffix": convertStringArrToInterface(condition.MatchesSuffix),
10931092
}
1093+
if condition.Age != nil {
1094+
ruleCondition["age"] = int(*condition.Age)
1095+
}
10941096
if condition.IsLive == nil {
10951097
ruleCondition["with_state"] = "ANY"
10961098
} else {

0 commit comments

Comments
 (0)