Documentation
¶
Index ¶
- Constants
- Variables
- type ContractViolation
- type Evaluator
- type LintWarning
- type OPA
- func (o *OPA) CheckContract(filename string, src string, schema cue.Value) ([]ContractViolation, error)
- func (o *OPA) FileExtension() string
- func (o *OPA) ID() string
- func (o *OPA) Lint(filename string, src string) ([]LintWarning, error)
- func (o *OPA) RequiredFiles() []string
- func (o *OPA) Test(ctx context.Context, files map[string]string) (*TestResults, error)
- func (o *OPA) Validate(filename string, src string) []error
- type Registry
- type TestResults
Constants ¶
const OPAEvaluatorID = "opa"
const OPAMappingFile = "complytime-mapping.json"
OPAMappingFile is the filename the OPA provider requires in the content directory to map Rego package namespaces to assessment plan requirement IDs.
Variables ¶
var ErrNotFound = errors.New("evaluator not found")
ErrNotFound is returned when a requested evaluator is not in the registry.
Functions ¶
This section is empty.
Types ¶
type ContractViolation ¶
type ContractViolation struct {
Path string // The input.* path that was referenced (e.g., "input.metadata.name")
Location string // Location in the policy file (e.g., "policy.rego:12:5")
}
ContractViolation represents a policy reference that doesn't exist in the schema.
func (ContractViolation) Error ¶
func (v ContractViolation) Error() string
Error implements the error interface.
type Evaluator ¶
type Evaluator interface {
// ID returns the unique identifier for this evaluator (e.g., "opa").
ID() string
// Validate checks policy syntax and compilation without executing.
// Returns a list of validation errors (empty if valid).
Validate(filename string, src string) []error
// CheckContract validates that all input.* references in the policy
// exist in the provided CUE schema.
CheckContract(filename string, src string, schema cue.Value) ([]ContractViolation, error)
// Test executes policy unit tests.
// files is a map of filename -> source code.
Test(ctx context.Context, files map[string]string) (*TestResults, error)
// Lint performs static analysis and returns style/quality warnings.
// Returns nil/nil if linting is not available or not applicable.
Lint(filename string, src string) ([]LintWarning, error)
// FileExtension returns the expected file extension for this evaluator's policies.
FileExtension() string
// RequiredFiles returns filenames that must exist in the content
// directory alongside policy files for this evaluator to function
// at scan time (e.g., "complytime-mapping.json" for OPA).
// Returns nil if no additional files are required.
RequiredFiles() []string
}
Evaluator defines the interface for policy-language evaluators.
type LintWarning ¶
type LintWarning struct {
Rule string // Name of the lint rule that triggered
Message string // Human-readable warning message
Location string // Location in the policy file (e.g., "policy.rego:12:5")
}
LintWarning represents a non-fatal linting issue.
type OPA ¶
type OPA struct{}
OPA implements the Evaluator interface for Open Policy Agent policies.
func (*OPA) CheckContract ¶
func (*OPA) FileExtension ¶
func (*OPA) RequiredFiles ¶ added in v0.0.8
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps evaluator IDs to Evaluator implementations. Thread-safe for concurrent access.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry creates a registry pre-populated with the OPA evaluator.
func (*Registry) Get ¶
Get retrieves an evaluator by ID. Returns an error if the evaluator is not registered.