github.com/beauknowssoftware/makehcl@v0.0.0-20200322000747-1b9bb1e1c008/internal/parse2/varBlock.go (about) 1 package parse2 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/hcl/v2" 7 ) 8 9 type varBlock struct { 10 block *hcl.Block 11 attributes []attribute 12 } 13 14 func (blk *varBlock) initAttributes(gs scope) hcl.Diagnostics { 15 attrs, result := blk.block.Body.JustAttributes() 16 17 blk.attributes = make([]attribute, 0, len(attrs)) 18 19 for name, attr := range attrs { 20 gen := generic{attribute: attr} 21 attr := attribute{ 22 name: fmt.Sprintf("var.%v", name), 23 set: setOnObject("var", name), 24 fillable: &gen, 25 scope: gs, 26 dependencies: getDependencies("", gen.attribute.Expr), 27 } 28 blk.attributes = append(blk.attributes, attr) 29 } 30 31 return result 32 }