1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

refactor: use GetKind() from the cleanup policy interface (#8565)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
Mariam Fahmy 2023-10-09 11:06:32 +03:00 committed by GitHub
parent cd986849d5
commit adb789247a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View file

@ -91,7 +91,7 @@ func (p *CleanupPolicy) Validate(clusterResources sets.Set[string]) (errs field.
// GetKind returns the resource kind
func (p *CleanupPolicy) GetKind() string {
return p.Kind
return "CleanupPolicy"
}
// GetAPIVersion returns the resource kind
@ -170,7 +170,7 @@ func (p *ClusterCleanupPolicy) GetNextExecutionTime(time time.Time) (*time.Time,
// GetKind returns the resource kind
func (p *ClusterCleanupPolicy) GetKind() string {
return p.Kind
return "ClusterCleanupPolicy"
}
// GetAPIVersion returns the resource kind

View file

@ -53,13 +53,6 @@ func buildPolicyEventMessage(resp engineapi.RuleResponse, resource engineapi.Res
return b.String()
}
func getCleanupPolicyKind(policy kyvernov2alpha1.CleanupPolicyInterface) string {
if policy.IsNamespaced() {
return "CleanupPolicy"
}
return "ClusterCleanupPolicy"
}
func NewPolicyAppliedEvent(source Source, engineResponse engineapi.EngineResponse) Info {
resource := engineResponse.Resource
var bldr strings.Builder
@ -226,7 +219,7 @@ func NewPolicyExceptionEvents(engineResponse engineapi.EngineResponse, ruleResp
func NewCleanupPolicyEvent(policy kyvernov2alpha1.CleanupPolicyInterface, resource unstructured.Unstructured, err error) Info {
if err == nil {
return Info{
Kind: getCleanupPolicyKind(policy),
Kind: policy.GetKind(),
Namespace: policy.GetNamespace(),
Name: policy.GetName(),
RelatedAPIVersion: resource.GetAPIVersion(),
@ -240,7 +233,7 @@ func NewCleanupPolicyEvent(policy kyvernov2alpha1.CleanupPolicyInterface, resour
}
} else {
return Info{
Kind: getCleanupPolicyKind(policy),
Kind: policy.GetKind(),
Namespace: policy.GetNamespace(),
Name: policy.GetName(),
RelatedAPIVersion: resource.GetAPIVersion(),