mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
a5e082303d
* refactor: introduce autogen interface Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix linter Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
23 lines
716 B
Go
23 lines
716 B
Go
package engine
|
|
|
|
import (
|
|
"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(
|
|
logger logr.Logger,
|
|
policyContext engineapi.PolicyContext,
|
|
) engineapi.PolicyResponse {
|
|
resp := engineapi.NewPolicyResponse()
|
|
for _, rule := range autogen.Default.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
|
|
}
|