INNER CODE UNIT · Go
toAST
open-policy-agent/conftest · builtins/parse_config.go:176
func toAST(bctx rego.BuiltinContext, cfg any, contents []byte) (*ast.Term, error) {
val, err := ast.InterfaceToValue(cfg)
if err != nil {
return nil, fmt.Errorf("convert config to ast.Value: %w", err)
}
var loc *location.Location
if bctx.Location != nil {
loc = bctx.Location
} else {
loc = &ast.Location{
File: "-", // stdin
Text: contents,
}
}
return &ast.Term{Value: val, Location: loc}, nil
}