INNER CODE UNIT · Go

parseConfigFile

open-policy-agent/conftest · builtins/parse_config.go:79

func parseConfigFile(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) {
	path, err := decodeArg[string](op1)
	if err != nil {
		return nil, fmt.Errorf("decode args: %w", err)
	}
	filePath := filepath.Join(filepath.Dir(bctx.Location.File), path)

	parser, err := parser.NewFromPath(filePath)
	if err != nil {
		return nil, fmt.Errorf("create config parser: %w", err)
	}
	contents, err := os.ReadFile(filePath)
	if err != nil {
		return nil, fmt.Errorf("read config file %s: %w", filePath, err)
	}

	var cfg any
	if err := parser.Unmarshal(contents, &cfg); err != nil {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…