1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/pkg/validatingadmissionpolicy/utils.go
shuting 5f0d53fe34
feat: apply .matchConditions when generating reports (#9599)
* enable matchconditions for reports

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* update

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* add chainsaw tests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* fix: linter issues

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: move files

Signed-off-by: ShutingZhao <shuting@nirmata.com>

---------

Signed-off-by: ShutingZhao <shuting@nirmata.com>
2024-02-02 08:32:28 +00:00

63 lines
2.2 KiB
Go

package validatingadmissionpolicy
import (
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
"k8s.io/api/admissionregistration/v1alpha1"
"k8s.io/api/admissionregistration/v1beta1"
)
func convertRules(v1alpha1rules []v1alpha1.NamedRuleWithOperations) []v1beta1.NamedRuleWithOperations {
var v1beta1rules []v1beta1.NamedRuleWithOperations
for _, r := range v1alpha1rules {
v1beta1rules = append(v1beta1rules, v1beta1.NamedRuleWithOperations(r))
}
return v1beta1rules
}
func convertValidations(v1alpha1validations []v1alpha1.Validation) []v1beta1.Validation {
var v1beta1validations []v1beta1.Validation
for _, v := range v1alpha1validations {
v1beta1validations = append(v1beta1validations, v1beta1.Validation(v))
}
return v1beta1validations
}
func convertAuditAnnotations(v1alpha1auditanns []v1alpha1.AuditAnnotation) []v1beta1.AuditAnnotation {
var v1beta1auditanns []v1beta1.AuditAnnotation
for _, a := range v1alpha1auditanns {
v1beta1auditanns = append(v1beta1auditanns, v1beta1.AuditAnnotation(a))
}
return v1beta1auditanns
}
func convertMatchConditions(v1alpha1conditions []v1alpha1.MatchCondition) []v1beta1.MatchCondition {
var v1beta1conditions []v1beta1.MatchCondition
for _, m := range v1alpha1conditions {
v1beta1conditions = append(v1beta1conditions, v1beta1.MatchCondition(m))
}
return v1beta1conditions
}
func ConvertMatchConditionsV1(v1alpha1conditions []v1alpha1.MatchCondition) []admissionregistrationv1.MatchCondition {
var v1conditions []admissionregistrationv1.MatchCondition
for _, m := range v1alpha1conditions {
v1conditions = append(v1conditions, admissionregistrationv1.MatchCondition(m))
}
return v1conditions
}
func convertVariables(v1alpha1variables []v1alpha1.Variable) []v1beta1.Variable {
var v1beta1variables []v1beta1.Variable
for _, v := range v1alpha1variables {
v1beta1variables = append(v1beta1variables, v1beta1.Variable(v))
}
return v1beta1variables
}
func convertValidationActions(v1alpha1actions []v1alpha1.ValidationAction) []v1beta1.ValidationAction {
var v1beta1actions []v1beta1.ValidationAction
for _, a := range v1alpha1actions {
v1beta1actions = append(v1beta1actions, v1beta1.ValidationAction(a))
}
return v1beta1actions
}