Skip to content

Commit

Permalink
potential fix for a crash in google_storage_bucket when providers u…
Browse files Browse the repository at this point in the history
…pgrade to `4.42.0` (#6758) (#12922)

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Nov 1, 2022
1 parent 3942bf8 commit e9af719
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/6758.txt
@@ -0,0 +1,3 @@
```release-note:bug
storage: fixed a crash in `google_storage_bucket` when upgrading provider to version `4.42.0` with `lifecycle_rule.condition.age` unset
```
4 changes: 3 additions & 1 deletion google/resource_storage_bucket.go
Expand Up @@ -1080,7 +1080,6 @@ func flattenBucketLifecycleRuleAction(action *storage.BucketLifecycleRuleAction)

func flattenBucketLifecycleRuleCondition(condition *storage.BucketLifecycleRuleCondition) map[string]interface{} {
ruleCondition := map[string]interface{}{
"age": int(*condition.Age),
"created_before": condition.CreatedBefore,
"matches_storage_class": convertStringArrToInterface(condition.MatchesStorageClass),
"num_newer_versions": int(condition.NumNewerVersions),
Expand All @@ -1091,6 +1090,9 @@ func flattenBucketLifecycleRuleCondition(condition *storage.BucketLifecycleRuleC
"matches_prefix": convertStringArrToInterface(condition.MatchesPrefix),
"matches_suffix": convertStringArrToInterface(condition.MatchesSuffix),
}
if condition.Age != nil {
ruleCondition["age"] = int(*condition.Age)
}
if condition.IsLive == nil {
ruleCondition["with_state"] = "ANY"
} else {
Expand Down

0 comments on commit e9af719

Please sign in to comment.