mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 10:04:25 +00:00
fix: GVK fallback in policy context (#6648)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
b0243e1215
commit
3aa3c022f4
1 changed files with 6 additions and 2 deletions
|
@ -71,9 +71,13 @@ func (c *PolicyContext) RequestResource() metav1.GroupVersionResource {
|
|||
}
|
||||
|
||||
func (c *PolicyContext) ResourceKind() (schema.GroupVersionKind, string) {
|
||||
// TODO: fallback
|
||||
// if the top level GVK is empty, fallback to the GVK of the resource
|
||||
if c.gvk.Empty() {
|
||||
return c.newResource.GroupVersionKind(), ""
|
||||
if c.newResource.Object != nil {
|
||||
return c.newResource.GroupVersionKind(), ""
|
||||
} else {
|
||||
return c.oldResource.GroupVersionKind(), ""
|
||||
}
|
||||
}
|
||||
return c.gvk, c.subresource
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue