condition.IsLive can come back nil - avoid crash if it does. (#997)

This commit is contained in:
Nathan McKinley 2018-01-22 14:14:02 -08:00 committed by GitHub
parent 0133845a19
commit 535fc64a14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -546,13 +546,16 @@ func flattenBucketLifecycleRuleAction(action *storage.BucketLifecycleRuleAction)
}
func flattenBucketLifecycleRuleCondition(condition *storage.BucketLifecycleRuleCondition) map[string]interface{} {
return map[string]interface{}{
ruleCondition := map[string]interface{}{
"age": int(condition.Age),
"created_before": condition.CreatedBefore,
"is_live": *condition.IsLive,
"matches_storage_class": convertStringArrToInterface(condition.MatchesStorageClass),
"num_newer_versions": int(condition.NumNewerVersions),
}
if condition.IsLive != nil {
ruleCondition["is_live"] = *condition.IsLive
}
return ruleCondition
}
func resourceGCSBucketLifecycleCreateOrUpdate(d *schema.ResourceData, sb *storage.Bucket) error {