mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 18:38:40 +00:00
fix: Overridden request.operation is not considered by match/exclude with operations (#8361)
* fix: verifyImages w/ multiple entries is not consistent Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * clean Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix: Kyverno apply produces false positives when validating 'empty dangling' tags Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix: Overridden request.operation is not considered by match/exclude with operations Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
954415a311
commit
e3188fca8c
1 changed files with 7 additions and 1 deletions
|
@ -204,8 +204,11 @@ func (p *PolicyProcessor) makePolicyContext(
|
|||
}
|
||||
resourceValues = vals
|
||||
}
|
||||
if resourceValues["request.operation"] == "DELETE" {
|
||||
switch resourceValues["request.operation"] {
|
||||
case "DELETE":
|
||||
operation = kyvernov1.Delete
|
||||
case "UPDATE":
|
||||
operation = kyvernov1.Update
|
||||
}
|
||||
policyContext, err := engine.NewPolicyContext(
|
||||
jp,
|
||||
|
@ -217,6 +220,9 @@ func (p *PolicyProcessor) makePolicyContext(
|
|||
if err != nil {
|
||||
log.Log.Error(err, "failed to create policy context")
|
||||
}
|
||||
if operation == kyvernov1.Update {
|
||||
policyContext = policyContext.WithOldResource(resource)
|
||||
}
|
||||
policyContext = policyContext.
|
||||
WithPolicy(policy).
|
||||
WithNamespaceLabels(namespaceLabels).
|
||||
|
|
Loading…
Add table
Reference in a new issue