MCPcopy Create free account
hub / github.com/conforma/cli / NewInput

Function NewInput

internal/evaluation_target/input/input.go:40–70  ·  view source on GitHub ↗

NewInput returns a Input struct with FPath and evaluator ready to use

(ctx context.Context, paths []string, p policy.Policy)

Source from the content-addressed store, hash-verified

38
39// NewInput returns a Input struct with FPath and evaluator ready to use
40func 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}

Callers

nothing calls this directly

Calls 3

PolicySourcesFromFunction · 0.92
IsOpaEnabledFunction · 0.92
SpecMethod · 0.65

Tested by

no test coverage detected