github.com/hartzell/terraform@v0.8.6-0.20180503104400-0cc9e050ecd4/helper/customdiff/computed.go (about) 1 package customdiff 2 3 import ( 4 "github.com/hashicorp/terraform/helper/schema" 5 ) 6 7 // ComputedIf returns a CustomizeDiffFunc that sets the given key's new value 8 // as computed if the given condition function returns true. 9 func ComputedIf(key string, f ResourceConditionFunc) schema.CustomizeDiffFunc { 10 return func(d *schema.ResourceDiff, meta interface{}) error { 11 if f(d, meta) { 12 d.SetNewComputed(key) 13 } 14 return nil 15 } 16 }