Skip to content

Commit

Permalink
Add AsNative helper (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Jul 18, 2022
1 parent aabc284 commit 28c5530
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hclext/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ func PartialContent(body hcl.Body, schema *BodySchema) (*BodyContent, hcl.Diagno
return ret, diags
}

// AsNative returns self as hcl.Attributes
func (as Attributes) AsNative() hcl.Attributes {
ret := hcl.Attributes{}
for name, attr := range as {
ret[name] = attr.AsNative()
}
return ret
}

// AsNative returns self as hcl.Attribute
func (a *Attribute) AsNative() *hcl.Attribute {
return &hcl.Attribute{
Name: a.Name,
Expr: a.Expr,
Range: a.Range,
NameRange: a.NameRange,
}
}

// OfType filters the receiving block sequence by block type name,
// returning a new block sequence including only the blocks of the
// requested type.
Expand Down

0 comments on commit 28c5530

Please sign in to comment.