mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
b4a4e3a4f3
* refactor: engine handlers Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * refactor: don't process context/preconditions in invokeHandler Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
26 lines
738 B
Go
26 lines
738 B
Go
package engine
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-logr/logr"
|
|
"github.com/kyverno/kyverno/pkg/autogen"
|
|
engineapi "github.com/kyverno/kyverno/pkg/engine/api"
|
|
"github.com/kyverno/kyverno/pkg/engine/internal"
|
|
)
|
|
|
|
// GenerateResponse checks for validity of generate rule on the resource
|
|
func (e *engine) generateResponse(
|
|
ctx context.Context,
|
|
logger logr.Logger,
|
|
policyContext engineapi.PolicyContext,
|
|
) engineapi.PolicyResponse {
|
|
resp := engineapi.NewPolicyResponse()
|
|
for _, rule := range autogen.ComputeRules(policyContext.Policy()) {
|
|
logger := internal.LoggerWithRule(logger, rule)
|
|
if ruleResp := e.filterRule(rule, logger, policyContext); ruleResp != nil {
|
|
resp.Rules = append(resp.Rules, *ruleResp)
|
|
}
|
|
}
|
|
return resp
|
|
}
|