in module.go [147:190]
func (m *Module) parseVariable(b *hcl.Block, f *hcl.File) Variable {
content, _, _ := b.Body.PartialContent(&hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
{
Name: "description",
},
{
Name: "sensitive",
},
{
Name: "default",
},
{
Name: "nullable",
},
{
Name: "type",
},
},
})
attributes := content.Attributes
v := Variable{
Name: b.Labels[0],
Range: b.DefRange,
}
if desc, ok := attributes["description"]; ok {
v.Description = attributeValueString(desc, f)
}
if sensitive, ok := attributes["sensitive"]; ok {
v.Sensitive = attributeValueString(sensitive, f)
}
if defaultValue, ok := attributes["default"]; ok {
v.Default = attributeValueString(defaultValue, f)
}
if nullable, ok := attributes["nullable"]; ok {
v.Nullable = attributeValueString(nullable, f)
}
if t, ok := attributes["type"]; ok {
v.Type = attributeValueString(t, f)
}
// We don't compare position's change
v.Range = hcl.Range{}
return v
}