Parse generates an internal parsed policy representation from a YAML input file. The internal representation ensures that CEL expressions are tracked relative to where they occur within the file, thus making error messages relative to the whole file rather than the individual expression.
(src *Source)
| 528 | // where they occur within the file, thus making error messages relative to the whole |
| 529 | // file rather than the individual expression. |
| 530 | func (parser *Parser) Parse(src *Source) (*Policy, *cel.Issues) { |
| 531 | info := ast.NewSourceInfo(src) |
| 532 | errs := common.NewErrors(src) |
| 533 | iss := cel.NewIssuesWithSourceInfo(errs, info) |
| 534 | p := newParserImpl(parser.TagVisitor, info, src, iss, parser.inlineStyleVariables) |
| 535 | policy := p.parseYAML(src) |
| 536 | if iss.Err() != nil { |
| 537 | return nil, iss |
| 538 | } |
| 539 | return policy, nil |
| 540 | } |
| 541 | |
| 542 | // normalizeEntry extracts a key, value pair as the next two elements from the |
| 543 | // content slice. val source position information is normalized depending on style. |