github.com/terraform-linters/tflint@v0.51.2-0.20240520175844-3750771571b6/terraform/lang/data.go (about)

     1  package lang
     2  
     3  import (
     4  	"github.com/hashicorp/hcl/v2"
     5  	"github.com/terraform-linters/tflint/terraform/addrs"
     6  	"github.com/zclconf/go-cty/cty"
     7  )
     8  
     9  // Data is an interface whose implementations can provide cty.Value
    10  // representations of objects identified by referenceable addresses from
    11  // the addrs package.
    12  //
    13  // This interface will grow each time a new type of reference is added, and so
    14  // implementations outside of the Terraform codebases are not advised.
    15  //
    16  // Each method returns a suitable value and optionally some diagnostics. If the
    17  // returned diagnostics contains errors then the type of the returned value is
    18  // used to construct an unknown value of the same type which is then used in
    19  // place of the requested object so that type checking can still proceed. In
    20  // cases where it's not possible to even determine a suitable result type,
    21  // cty.DynamicVal is returned along with errors describing the problem.
    22  type Data interface {
    23  	GetCountAttr(addrs.CountAttr, hcl.Range) (cty.Value, hcl.Diagnostics)
    24  	GetForEachAttr(addrs.ForEachAttr, hcl.Range) (cty.Value, hcl.Diagnostics)
    25  	GetLocalValue(addrs.LocalValue, hcl.Range) (cty.Value, hcl.Diagnostics)
    26  	GetPathAttr(addrs.PathAttr, hcl.Range) (cty.Value, hcl.Diagnostics)
    27  	GetTerraformAttr(addrs.TerraformAttr, hcl.Range) (cty.Value, hcl.Diagnostics)
    28  	GetInputVariable(addrs.InputVariable, hcl.Range) (cty.Value, hcl.Diagnostics)
    29  }