mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-05 15:37:19 +00:00
* feat: enable custom data in policy reports using properties Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: dont throw error in variable substitution for properties Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> --------- Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
21 lines
612 B
Go
21 lines
612 B
Go
package internal
|
|
|
|
import (
|
|
"github.com/go-logr/logr"
|
|
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
|
enginecontext "github.com/kyverno/kyverno/pkg/engine/context"
|
|
"github.com/kyverno/kyverno/pkg/engine/variables"
|
|
)
|
|
|
|
func SubstitutePropertiesInRule(log logr.Logger, rule *kyvernov1.Rule, jsonContext enginecontext.Interface) error {
|
|
if len(rule.ReportProperties) == 0 {
|
|
return nil
|
|
}
|
|
properties := rule.ReportProperties
|
|
updatedProperties, err := variables.SubstituteAllInType(log, jsonContext, &properties)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
rule.ReportProperties = *updatedProperties
|
|
return nil
|
|
}
|