github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/not-internal/configs/provider_meta.go (about)

     1  package configs
     2  
     3  import "github.com/hashicorp/hcl/v2"
     4  
     5  // ProviderMeta represents a "provider_meta" block inside a "terraform" block
     6  // in a module or file.
     7  type ProviderMeta struct {
     8  	Provider string
     9  	Config   hcl.Body
    10  
    11  	ProviderRange hcl.Range
    12  	DeclRange     hcl.Range
    13  }
    14  
    15  func decodeProviderMetaBlock(block *hcl.Block) (*ProviderMeta, hcl.Diagnostics) {
    16  	// provider_meta must be a static map. We can verify this by attempting to
    17  	// evaluate the values.
    18  	attrs, diags := block.Body.JustAttributes()
    19  	if diags.HasErrors() {
    20  		return nil, diags
    21  	}
    22  
    23  	for _, attr := range attrs {
    24  		_, d := attr.Expr.Value(nil)
    25  		diags = append(diags, d...)
    26  	}
    27  
    28  	// verify that the local name is already localized or produce an error.
    29  	diags = append(diags, checkProviderNameNormalized(block.Labels[0], block.DefRange)...)
    30  
    31  	return &ProviderMeta{
    32  		Provider:      block.Labels[0],
    33  		ProviderRange: block.LabelRanges[0],
    34  		Config:        block.Body,
    35  		DeclRange:     block.DefRange,
    36  	}, diags
    37  }