From 3e86ddedeb2a32607b9810b072d8e32079d417b5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 1 Nov 2022 11:48:00 -0700 Subject: [PATCH] potential fix for a crash in `google_storage_bucket` when providers upgrade to `4.42.0` (#6758) (#12922) Signed-off-by: Modular Magician Signed-off-by: Modular Magician --- .changelog/6758.txt | 3 +++ google/resource_storage_bucket.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changelog/6758.txt diff --git a/.changelog/6758.txt b/.changelog/6758.txt new file mode 100644 index 00000000000..947d417adbf --- /dev/null +++ b/.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 +``` diff --git a/google/resource_storage_bucket.go b/google/resource_storage_bucket.go index 213a3bd3ea6..8fcd3ed5fd4 100644 --- a/google/resource_storage_bucket.go +++ b/google/resource_storage_bucket.go @@ -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), @@ -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 {