mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 02:45:06 +00:00
fix: use the correct API version for VAPs in the generated events (#9392)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com> Co-authored-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
This commit is contained in:
parent
14b4bd7d2c
commit
b4acbdea2c
2 changed files with 12 additions and 4 deletions
|
@ -23,6 +23,8 @@ type GenericPolicy interface {
|
|||
GetPolicy() interface{}
|
||||
// GetType returns policy type
|
||||
GetType() PolicyType
|
||||
// GetAPIVersion returns policy API version
|
||||
GetAPIVersion() string
|
||||
// GetName returns policy name
|
||||
GetName() string
|
||||
// GetNamespace returns policy namespace
|
||||
|
@ -51,6 +53,10 @@ func (p *KyvernoPolicy) GetType() PolicyType {
|
|||
return KyvernoPolicyType
|
||||
}
|
||||
|
||||
func (p *KyvernoPolicy) GetAPIVersion() string {
|
||||
return "kyverno.io/v1"
|
||||
}
|
||||
|
||||
func (p *KyvernoPolicy) GetName() string {
|
||||
return p.policy.GetName()
|
||||
}
|
||||
|
@ -97,6 +103,10 @@ func (p *ValidatingAdmissionPolicy) GetType() PolicyType {
|
|||
return ValidatingAdmissionPolicyType
|
||||
}
|
||||
|
||||
func (p *ValidatingAdmissionPolicy) GetAPIVersion() string {
|
||||
return "admissionregistration.k8s.io/v1alpha1"
|
||||
}
|
||||
|
||||
func (p *ValidatingAdmissionPolicy) GetName() string {
|
||||
return p.policy.GetName()
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ func NewPolicyFailEvent(source Source, reason Reason, engineResponse engineapi.E
|
|||
}
|
||||
pol := engineResponse.Policy()
|
||||
regarding := corev1.ObjectReference{
|
||||
// TODO: iirc it's not safe to assume api version is set
|
||||
APIVersion: "kyverno.io/v1",
|
||||
APIVersion: pol.GetAPIVersion(),
|
||||
Kind: pol.GetKind(),
|
||||
Name: pol.GetName(),
|
||||
Namespace: pol.GetNamespace(),
|
||||
|
@ -94,8 +93,7 @@ func NewPolicyAppliedEvent(source Source, engineResponse engineapi.EngineRespons
|
|||
action = ResourcePassed
|
||||
}
|
||||
regarding := corev1.ObjectReference{
|
||||
// TODO: iirc it's not safe to assume api version is set
|
||||
APIVersion: "kyverno.io/v1",
|
||||
APIVersion: policy.GetAPIVersion(),
|
||||
Kind: policy.GetKind(),
|
||||
Name: policy.GetName(),
|
||||
Namespace: policy.GetNamespace(),
|
||||
|
|
Loading…
Add table
Reference in a new issue