MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Run

Method Run

app/cli/pkg/action/policy_develop_lint.go:45–67  ·  view source on GitHub ↗
(_ context.Context, opts *PolicyLintOpts)

Source from the content-addressed store, hash-verified

43}
44
45func (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}

Callers 1

newPolicyDevelopLintCmdFunction · 0.95

Calls 4

LookupFunction · 0.92
HasErrorsMethod · 0.80
ErrorMethod · 0.65
ValidateMethod · 0.45

Tested by

no test coverage detected