(_ context.Context, opts *PolicyLintOpts)
| 43 | } |
| 44 | |
| 45 | func (action *PolicyLint) Run(_ context.Context, opts *PolicyLintOpts) (*PolicyLintResult, error) { |
| 46 | // Read policies |
| 47 | policy, err := policydevel.Lookup(opts.PolicyPath, opts.RegalConfig, opts.Format) |
| 48 | if err != nil { |
| 49 | return nil, err |
| 50 | } |
| 51 | |
| 52 | // Run all validations |
| 53 | policy.Validate() |
| 54 | |
| 55 | // Prepare result |
| 56 | result := &PolicyLintResult{ |
| 57 | Valid: !policy.HasErrors(), |
| 58 | Errors: make([]string, 0, len(policy.Errors)), |
| 59 | } |
| 60 | |
| 61 | // Convert validation errors to strings |
| 62 | for _, err := range policy.Errors { |
| 63 | result.Errors = append(result.Errors, err.Error()) |
| 64 | } |
| 65 | |
| 66 | return result, nil |
| 67 | } |
no test coverage detected