Skip to content

Commit

Permalink
Action and condition blocks of a lifecycle_rule block are both requir…
Browse files Browse the repository at this point in the history
…ed, use MinItems in schema to enforce
  • Loading branch information
pdecat committed Jul 4, 2017
1 parent 9acd425 commit 326e42e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions google/resource_storage_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func resourceStorageBucket() *schema.Resource {
"action": {
Type: schema.TypeSet,
Required: true,
MinItems: 1,
MaxItems: 1,
Set: resourceGCSBucketLifecycleRuleActionHash,
Elem: &schema.Resource{
Expand All @@ -106,6 +107,7 @@ func resourceStorageBucket() *schema.Resource {
"condition": {
Type: schema.TypeSet,
Required: true,
MinItems: 1,
MaxItems: 1,
Set: resourceGCSBucketLifecycleRuleConditionHash,
Elem: &schema.Resource{
Expand Down Expand Up @@ -484,10 +486,6 @@ func resourceGCSBucketLifecycleCreateOrUpdate(d *schema.ResourceData, sb *storag
if v, ok := lifecycle_rule["condition"]; ok {
condition := v.(*schema.Set).List()[0].(map[string]interface{})

if len(condition) < 1 {
return fmt.Errorf("At least one condition element is required")
}

target_lifecycle_rule.Condition = &storage.BucketLifecycleRuleCondition{}

if v, ok := condition["age"]; ok {
Expand Down

0 comments on commit 326e42e

Please sign in to comment.