1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 07:57:07 +00:00

violation struct update

This commit is contained in:
shivkumar dudhani 2019-06-26 18:02:01 -07:00
parent 10aadb1efa
commit 8324949f50
2 changed files with 14 additions and 8 deletions

View file

@ -81,11 +81,12 @@ type Status struct {
// Violation for the policy
type Violation struct {
Kind string `json:"kind,omitempty"`
Resource string `json:"resource,omitempty"`
Rule string `json:"rule,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Rule string `json:"rule,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View file

@ -64,7 +64,7 @@ func (b *builder) processViolation(info Info) error {
newViolation := info.Violation
for _, violation := range modifiedPolicy.Status.Violations {
ok, err := b.isActive(info.Kind, violation.Resource)
ok, err := b.isActive(info.Kind, violation.Name)
if err != nil {
glog.Error(err)
continue
@ -102,9 +102,14 @@ func (b *builder) isActive(kind string, resource string) (bool, error) {
}
//NewViolation return new policy violation
func NewViolation(policyName string, kind string, resource string, rule string) Info {
func NewViolation(policyName string, kind string, rname string, rnamespace string, ruleName string, reason string, msg string) Info {
return Info{Policy: policyName,
Violation: types.Violation{
Kind: kind, Resource: resource, Rule: rule},
Kind: kind,
Name: rname,
Namespace: rnamespace,
Rule: ruleName,
Reason: reason,
},
}
}