1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 07:57:07 +00:00
kyverno/pkg/engine/api/engine.go
Charles-Edouard Brétéché 7a1d4374c6
refactor: move client out of policy context (#6233)
* refactor: move client out of policy context

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 test

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-02-07 15:09:15 +00:00

50 lines
1.4 KiB
Go

package api
import (
"context"
kyvernov1beta1 "github.com/kyverno/kyverno/api/kyverno/v1beta1"
"github.com/kyverno/kyverno/pkg/registryclient"
)
// Engine is the main interface to run policies against resources
type Engine interface {
// Validate applies validation rules from policy on the resource
Validate(
ctx context.Context,
policyContext PolicyContext,
) *EngineResponse
// Mutate performs mutation. Overlay first and then mutation patches
Mutate(
ctx context.Context,
policyContext PolicyContext,
) *EngineResponse
// VerifyAndPatchImages ...
VerifyAndPatchImages(
ctx context.Context,
rclient registryclient.Client,
policyContext PolicyContext,
) (*EngineResponse, *ImageVerificationMetadata)
// ApplyBackgroundChecks checks for validity of generate and mutateExisting rules on the resource
// 1. validate variables to be substitute in the general ruleInfo (match,exclude,condition)
// - the caller has to check the ruleResponse to determine whether the path exist
//
// 2. returns the list of rules that are applicable on this policy and resource, if 1 succeed
ApplyBackgroundChecks(
policyContext PolicyContext,
) *EngineResponse
// GenerateResponse checks for validity of generate rule on the resource
GenerateResponse(
policyContext PolicyContext,
gr kyvernov1beta1.UpdateRequest,
) *EngineResponse
ContextLoader(
policyContext PolicyContext,
ruleName string,
) ContextLoader
}