Skip to content

Commit

Permalink
duration
Browse files Browse the repository at this point in the history
  • Loading branch information
eraac authored and slevenick committed Dec 8, 2020
1 parent 55c20c2 commit 48bbe61
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions third_party/terraform/resources/resource_bigtable_gc_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func resourceBigtableGCPolicy() *schema.Resource {
Optional: true,
ForceNew: true,
Description: `GC policy that applies to all cells older than the given age.`,
ExactlyOneOf: []string{"max_age.0.days", "max_age.0.seconds"},
ExactlyOneOf: []string{"max_age.0.days", "max_age.0.duration"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"days": {
Type: schema.TypeInt,
Optional: true,
Deprecated: "Deprecated in favor of seconds",
Deprecated: "Deprecated in favor of duration",
Description: `Number of days before applying GC policy.`,
},
"duration": {
Expand Down Expand Up @@ -271,10 +271,12 @@ func generateBigtableGCPolicy(d *schema.ResourceData) (bigtable.GCPolicy, error)
}

func getMaxAgeDuration(values map[string]interface{}) (time.Duration, error) {
d := values["seconds"].(string)
if d == "" {
d = values["days"].(string)
d := values["duration"].(string)
if d != "" {
return time.ParseDuration(d)
}

return time.ParseDuration(d)
days := values["days"].(int)

return time.Hour * 24 * time.Duration(days), nil
}

0 comments on commit 48bbe61

Please sign in to comment.