INNER CODE UNIT · Go
registerParseCombinedConfigFiles
open-policy-agent/conftest · builtins/parse_config.go:44
func registerParseCombinedConfigFiles() {
decl := rego.Function{
Name: "parse_combined_config_files",
Decl: types.NewFunction(
types.Args(types.NewArray(nil, types.S)), // paths to configuration files
types.NewObject(nil, types.NewDynamicProperty(types.S, types.NewAny())), // map[string]any aka JSON
),
}
rego.RegisterBuiltin1(&decl, parseCombinedConfigFiles)
}
// parseConfig takes a parser name and configuration as strings and returns the
// parsed configuration as a Rego object. This can be used to parse all of the
// configuration formats conftest supports in-line in Rego policies.
func parseConfig(bctx rego.BuiltinContext, op1, op2 *ast.Term) (*ast.Term, error) {
args, err := decodeArgs[string](op1, op2)
if err != nil {
return nil, fmt.Errorf("decode args: %w", err)