github.com/jsoriano/terraform@v0.6.7-0.20151026070445-8b70867fdd95/terraform/eval_ignore_changes.go (about) 1 package terraform 2 3 import ( 4 "github.com/hashicorp/terraform/config" 5 "strings" 6 ) 7 8 // EvalIgnoreChanges is an EvalNode implementation that removes diff 9 // attributes if their name matches names provided by the resource's 10 // IgnoreChanges lifecycle. 11 type EvalIgnoreChanges struct { 12 Resource *config.Resource 13 Diff **InstanceDiff 14 } 15 16 func (n *EvalIgnoreChanges) Eval(ctx EvalContext) (interface{}, error) { 17 if n.Diff == nil || *n.Diff == nil || n.Resource == nil || n.Resource.Id() == "" { 18 return nil, nil 19 } 20 21 diff := *n.Diff 22 ignoreChanges := n.Resource.Lifecycle.IgnoreChanges 23 24 for _, ignoredName := range ignoreChanges { 25 for name := range diff.Attributes { 26 if strings.HasPrefix(name, ignoredName) { 27 delete(diff.Attributes, name) 28 } 29 } 30 } 31 32 return nil, nil 33 }