Skip to content

Commit 28c5530

Browse files
authored
Add AsNative helper (#170)
1 parent aabc284 commit 28c5530

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

hclext/structure.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,25 @@ func PartialContent(body hcl.Body, schema *BodySchema) (*BodyContent, hcl.Diagno
158158
return ret, diags
159159
}
160160

161+
// AsNative returns self as hcl.Attributes
162+
func (as Attributes) AsNative() hcl.Attributes {
163+
ret := hcl.Attributes{}
164+
for name, attr := range as {
165+
ret[name] = attr.AsNative()
166+
}
167+
return ret
168+
}
169+
170+
// AsNative returns self as hcl.Attribute
171+
func (a *Attribute) AsNative() *hcl.Attribute {
172+
return &hcl.Attribute{
173+
Name: a.Name,
174+
Expr: a.Expr,
175+
Range: a.Range,
176+
NameRange: a.NameRange,
177+
}
178+
}
179+
161180
// OfType filters the receiving block sequence by block type name,
162181
// returning a new block sequence including only the blocks of the
163182
// requested type.

0 commit comments

Comments
 (0)