4 "github.com/hashicorp/hcl2/hcl"
5 "github.com/zclconf/go-cty/cty"
8 type iteration struct {
12 Inherited map[string]*iteration
15 func (s *expandSpec) MakeIteration(key, value cty.Value) *iteration {
17 IteratorName: s.iteratorName,
20 Inherited: s.inherited,
24 func (i *iteration) Object() cty.Value {
25 return cty.ObjectVal(map[string]cty.Value{
31 func (i *iteration) EvalContext(base *hcl.EvalContext) *hcl.EvalContext {
32 new := base.NewChild()
35 new.Variables = map[string]cty.Value{}
36 for name, otherIt := range i.Inherited {
37 new.Variables[name] = otherIt.Object()
39 new.Variables[i.IteratorName] = i.Object()
45 func (i *iteration) MakeChild(iteratorName string, key, value cty.Value) *iteration {
47 // Create entirely new root iteration, then
49 IteratorName: iteratorName,
55 inherited := map[string]*iteration{}
56 for name, otherIt := range i.Inherited {
57 inherited[name] = otherIt
59 inherited[i.IteratorName] = i
61 IteratorName: iteratorName,