mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-10 18:06:55 +00:00
25 lines
658 B
Go
25 lines
658 B
Go
package api
|
|
|
|
// PolicyResponse policy application response
|
|
type PolicyResponse struct {
|
|
// Stats contains policy statistics
|
|
Stats PolicyStats
|
|
// Rules contains policy rules responses
|
|
Rules []RuleResponse
|
|
}
|
|
|
|
func (pr *PolicyResponse) Add(stats ExecutionStats, responses ...RuleResponse) {
|
|
for _, response := range responses {
|
|
pr.Rules = append(pr.Rules, response.WithStats(stats))
|
|
status := response.Status()
|
|
if status == RuleStatusPass || status == RuleStatusFail {
|
|
pr.Stats.RulesAppliedCount++
|
|
} else if status == RuleStatusError {
|
|
pr.Stats.RulesErrorCount++
|
|
}
|
|
}
|
|
}
|
|
|
|
func NewPolicyResponse() PolicyResponse {
|
|
return PolicyResponse{}
|
|
}
|