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:
parent
10aadb1efa
commit
8324949f50
2 changed files with 14 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue