NewInput returns a Input struct with FPath and evaluator ready to use
(ctx context.Context, paths []string, p policy.Policy)
| 38 | |
| 39 | // NewInput returns a Input struct with FPath and evaluator ready to use |
| 40 | func NewInput(ctx context.Context, paths []string, p policy.Policy) (*Input, error) { |
| 41 | i := &Input{ |
| 42 | Paths: paths, |
| 43 | } |
| 44 | |
| 45 | for _, sourceGroup := range p.Spec().Sources { |
| 46 | // Todo: Make each fetch run concurrently |
| 47 | policySources := source.PolicySourcesFrom(sourceGroup) |
| 48 | |
| 49 | for _, policySource := range policySources { |
| 50 | log.Debugf("policySource: %#v", policySource) |
| 51 | } |
| 52 | |
| 53 | var c evaluator.Evaluator |
| 54 | var err error |
| 55 | if utils.IsOpaEnabled() { |
| 56 | c, err = newOPAEvaluator(ctx, policySources, p, sourceGroup, nil) |
| 57 | } else { |
| 58 | c, err = newConftestEvaluator(ctx, policySources, p, sourceGroup) |
| 59 | } |
| 60 | if err != nil { |
| 61 | log.Debug("Failed to initialize the evaluator!") |
| 62 | return nil, err |
| 63 | } |
| 64 | |
| 65 | log.Debug("Evaluator initialized") |
| 66 | i.Evaluators = append(i.Evaluators, c) |
| 67 | |
| 68 | } |
| 69 | return i, nil |
| 70 | } |
nothing calls this directly
no test coverage detected