(rawAttrs hcl.Attributes)
| 126 | } |
| 127 | |
| 128 | func (b *expandBody) prepareAttributes(rawAttrs hcl.Attributes) hcl.Attributes { |
| 129 | if len(b.hiddenAttrs) == 0 && b.iteration == nil && len(b.valueMarks) == 0 { |
| 130 | // Easy path: just pass through the attrs from the original body verbatim |
| 131 | return rawAttrs |
| 132 | } |
| 133 | |
| 134 | // Otherwise we have some work to do: we must filter out any attributes |
| 135 | // that are hidden (since a previous PartialContent call already saw these) |
| 136 | // and wrap the expressions of the inner attributes so that they will |
| 137 | // have access to our iteration variables. |
| 138 | attrs := make(hcl.Attributes, len(rawAttrs)) |
| 139 | for name, rawAttr := range rawAttrs { |
| 140 | if _, hidden := b.hiddenAttrs[name]; hidden { |
| 141 | continue |
| 142 | } |
| 143 | if b.iteration != nil { |
| 144 | attr := *rawAttr // shallow copy so we can mutate it |
| 145 | attr.Expr = exprWrap{ |
| 146 | Expression: attr.Expr, |
| 147 | i: b.iteration, |
| 148 | resultMarks: b.valueMarks, |
| 149 | } |
| 150 | attrs[name] = &attr |
| 151 | } else { |
| 152 | // If we have no active iteration then no wrapping is required |
| 153 | // unless we have marks to apply. |
| 154 | if len(b.valueMarks) != 0 { |
| 155 | attr := *rawAttr // shallow copy so we can mutate it |
| 156 | attr.Expr = exprWrap{ |
| 157 | Expression: attr.Expr, |
| 158 | resultMarks: b.valueMarks, |
| 159 | } |
| 160 | attrs[name] = &attr |
| 161 | } else { |
| 162 | attrs[name] = rawAttr |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | return attrs |
| 167 | } |
| 168 | |
| 169 | func (b *expandBody) expandBlocks(schema *hcl.BodySchema, rawBlocks hcl.Blocks, partial bool) (hcl.Blocks, hcl.Diagnostics) { |
| 170 | var blocks hcl.Blocks |
no outgoing calls
no test coverage detected