@@ -2,7 +2,6 @@ package decoder
2
2
3
3
import (
4
4
"context"
5
- "log"
6
5
"sort"
7
6
8
7
"github.com/zclconf/go-cty/cty"
@@ -48,20 +47,17 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
48
47
return tokens
49
48
}
50
49
50
+ // TODO: test for count extension used in root BodySchema
51
51
if bodySchema .Extensions != nil {
52
- ctx = icontext .WithExtensions (ctx , bodySchema .Extensions )
53
52
if bodySchema .Extensions .Count {
54
53
if _ , ok := body .Attributes ["count" ]; ok {
55
54
// append to context we need count provided
56
55
ctx = icontext .WithActiveCount (ctx )
57
- log .Printf ("Found Expression: " )
58
56
}
59
57
}
60
58
}
61
59
62
60
for name , attr := range body .Attributes {
63
-
64
- log .Printf ("Found: %q / %v+" , name , bodySchema .Extensions )
65
61
attrSchema , ok := bodySchema .Attributes [name ]
66
62
if ! ok {
67
63
if bodySchema .Extensions != nil && name == "count" && bodySchema .Extensions .Count {
@@ -93,8 +89,6 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
93
89
})
94
90
95
91
ec := ExprConstraints (attrSchema .Expr )
96
- countAvailable := icontext .ActiveCountFromContext (ctx )
97
- log .Printf ("Found Expression: countAvailable %t" , countAvailable )
98
92
tokens = append (tokens , d .tokensForExpression (ctx , attr .Expr , ec )... )
99
93
}
100
94
@@ -136,6 +130,15 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
136
130
}
137
131
138
132
if block .Body != nil {
133
+ // TODO: Test for count.index in a sub-block
134
+ if blockSchema .Body != nil && blockSchema .Body .Extensions != nil {
135
+ if blockSchema .Body .Extensions .Count {
136
+ if _ , ok := block .Body .Attributes ["count" ]; ok {
137
+ // append to context we need count provided
138
+ ctx = icontext .WithActiveCount (ctx )
139
+ }
140
+ }
141
+ }
139
142
tokens = append (tokens , d .tokensForBody (ctx , block .Body , blockSchema .Body , blockModifiers )... )
140
143
}
141
144
@@ -176,7 +179,6 @@ func (d *PathDecoder) tokensForExpression(ctx context.Context, expr hclsyntax.Ex
176
179
}
177
180
countAvailable := icontext .ActiveCountFromContext (ctx )
178
181
// TODO why is countAvailable not true here?
179
- log .Printf ("Found Expression: %t / %t - %v+" , countAvailable , address .Equals (countIndexAttr ), address )
180
182
// if address.Equals(countIndexAttr) && countAvailable {
181
183
if address .Equals (countIndexAttr ) && countAvailable {
182
184
traversal := eType .AsTraversal ()
0 commit comments