diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/config/module/tree.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/config/module/tree.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/config/module/tree.go b/vendor/github.com/hashicorp/terraform/config/module/tree.go index b6f90fd..4b0b153 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/tree.go +++ b/vendor/github.com/hashicorp/terraform/config/module/tree.go | |||
@@ -92,6 +92,25 @@ func (t *Tree) Children() map[string]*Tree { | |||
92 | return t.children | 92 | return t.children |
93 | } | 93 | } |
94 | 94 | ||
95 | // DeepEach calls the provided callback for the receiver and then all of | ||
96 | // its descendents in the tree, allowing an operation to be performed on | ||
97 | // all modules in the tree. | ||
98 | // | ||
99 | // Parents will be visited before their children but otherwise the order is | ||
100 | // not defined. | ||
101 | func (t *Tree) DeepEach(cb func(*Tree)) { | ||
102 | t.lock.RLock() | ||
103 | defer t.lock.RUnlock() | ||
104 | t.deepEach(cb) | ||
105 | } | ||
106 | |||
107 | func (t *Tree) deepEach(cb func(*Tree)) { | ||
108 | cb(t) | ||
109 | for _, c := range t.children { | ||
110 | c.deepEach(cb) | ||
111 | } | ||
112 | } | ||
113 | |||
95 | // Loaded says whether or not this tree has been loaded or not yet. | 114 | // Loaded says whether or not this tree has been loaded or not yet. |
96 | func (t *Tree) Loaded() bool { | 115 | func (t *Tree) Loaded() bool { |
97 | t.lock.RLock() | 116 | t.lock.RLock() |