1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 18:38:40 +00:00

fix: deep copy resource in cli when operation is update (#9191)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-12-18 16:31:19 +01:00 committed by GitHub
parent e68bca6563
commit 3f865d2038
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,7 +234,8 @@ func (p *PolicyProcessor) makePolicyContext(
return nil, fmt.Errorf("failed to create policy context (%w)", err)
}
if operation == kyvernov1.Update {
policyContext = policyContext.WithOldResource(resource)
resource := resource.DeepCopy()
policyContext = policyContext.WithOldResource(*resource)
if err := policyContext.JSONContext().AddOldResource(resource.Object); err != nil {
return nil, fmt.Errorf("failed to update old resource in json context (%w)", err)
}