1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/engine/generation.go

27 lines
738 B
Go
Raw Normal View History

2019-05-14 01:17:28 +00:00
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
}