github.com/beauknowssoftware/makehcl@v0.0.0-20200322000747-1b9bb1e1c008/internal/parse2/generic.go (about)

     1  package parse2
     2  
     3  import (
     4  	"github.com/hashicorp/hcl/v2"
     5  	"github.com/zclconf/go-cty/cty"
     6  )
     7  
     8  type generic struct {
     9  	attribute *hcl.Attribute
    10  	val       cty.Value
    11  	ctx       *hcl.EvalContext
    12  }
    13  
    14  func (a *generic) fill(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
    15  	val, diag := a.attribute.Expr.Value(ctx)
    16  	if diag.HasErrors() {
    17  		return a.val, diag
    18  	}
    19  
    20  	a.val = val
    21  	a.ctx = ctx
    22  
    23  	return val, nil
    24  }