github.com/avenga/couper@v1.12.2/config/parser/load.go (about)

     1  package parser
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/hashicorp/hcl/v2/hclparse"
     7  	"github.com/hashicorp/hcl/v2/hclsyntax"
     8  )
     9  
    10  func Load(src []byte, name string) (*hclsyntax.Body, error) {
    11  	parser := hclparse.NewParser()
    12  
    13  	file, diags := parser.ParseHCL(src, name)
    14  	if file == nil || file.Body == nil {
    15  		return nil, diags
    16  	}
    17  
    18  	hsbody, ok := file.Body.(*hclsyntax.Body)
    19  	if !ok {
    20  		return nil, fmt.Errorf("couper configuration must be in native HCL syntax")
    21  	}
    22  	return hsbody, nil
    23  }