Refactor Policy Enforcer to Policy Checker
- Renamed the `PolicyEnforcer` interface and related implementations to `PolicyChecker` for clarity and consistency. - Updated configuration keys in YAML files to reflect the new `checkPolicy` terminology. - Adjusted related code, tests, and documentation to support the new naming convention and ensure compatibility. - Enhanced comments and examples for the `checkPolicy` configuration to improve usability.
This commit is contained in:
@@ -316,10 +316,18 @@ func extractSchemaVersion(body []byte) string {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// newEnforcePolicyStep creates and returns the enforcePolicy step after validation.
|
||||
func newEnforcePolicyStep(policyEnforcer definition.PolicyEnforcer) (definition.Step, error) {
|
||||
if policyEnforcer == nil {
|
||||
return nil, fmt.Errorf("invalid config: PolicyEnforcer plugin not configured")
|
||||
}
|
||||
return policyEnforcer, nil
|
||||
// checkPolicyStep adapts PolicyChecker into the Step interface.
|
||||
type checkPolicyStep struct {
|
||||
checker definition.PolicyChecker
|
||||
}
|
||||
|
||||
func newCheckPolicyStep(policyChecker definition.PolicyChecker) (definition.Step, error) {
|
||||
if policyChecker == nil {
|
||||
return nil, fmt.Errorf("invalid config: PolicyChecker plugin not configured")
|
||||
}
|
||||
return &checkPolicyStep{checker: policyChecker}, nil
|
||||
}
|
||||
|
||||
func (s *checkPolicyStep) Run(ctx *model.StepContext) error {
|
||||
return s.checker.CheckPolicy(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user