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

remove success event for policy

This commit is contained in:
Shuting Zhao 2019-06-27 10:42:56 -07:00
parent cd7b5a59a5
commit 1b00b35e36
2 changed files with 8 additions and 8 deletions

View file

@ -219,7 +219,7 @@ func createEvents(eventController event.Generator, policyInfos []*info.PolicyInf
e := event.NewEvent("Policy", "", policyInfo.Name, event.PolicyApplied, event.SPolicyApply, policyInfo.Name)
events = append(events, e)
// Policy applied succesfully on resource
e = event.NewEvent(policyInfo.RKind, policyInfo.RNamespace, policyInfo.RName, event.PolicyApplied, event.SRuleApply, strings.Join(sruleNames, ";"), policyInfo.RName)
e = event.NewEvent(policyInfo.RKind, policyInfo.RNamespace, policyInfo.RName, event.PolicyApplied, event.SRulesApply, strings.Join(sruleNames, ";"), policyInfo.RName)
events = append(events, e)
}
}

View file

@ -183,8 +183,8 @@ func (ws *WebhookServer) HandleMutation(request *v1beta1.AdmissionRequest) *v1be
policyInfos = append(policyInfos, policyInfo)
}
// eventsInfo := NewEventInfoFromPolicyInfo(policyInfos)
// ws.eventController.Add(eventsInfo)
eventsInfo := newEventInfoFromPolicyInfo(policyInfos)
ws.eventController.Add(eventsInfo)
ok, msg := isAdmSuccesful(policyInfos)
if ok {
@ -272,6 +272,9 @@ func (ws *WebhookServer) HandleValidation(request *v1beta1.AdmissionRequest) *v1
policyInfos = append(policyInfos, policyInfo)
}
eventsInfo := newEventInfoFromPolicyInfo(policyInfos)
ws.eventController.Add(eventsInfo)
// If Validation fails then reject the request
ok, msg := isAdmSuccesful(policyInfos)
if !ok {
@ -382,7 +385,7 @@ func (ws *WebhookServer) bodyToAdmissionReview(request *http.Request, writer htt
const policyKind = "Policy"
func NewEventInfoFromPolicyInfo(policyInfoList []*info.PolicyInfo) []*event.Info {
func newEventInfoFromPolicyInfo(policyInfoList []*info.PolicyInfo) []*event.Info {
var eventsInfo []*event.Info
ok, msg := isAdmSuccesful(policyInfoList)
@ -392,10 +395,7 @@ func NewEventInfoFromPolicyInfo(policyInfoList []*info.PolicyInfo) []*event.Info
eventsInfo = append(eventsInfo,
event.NewEvent(pi.RKind, pi.RNamespace, pi.RName, event.PolicyApplied, event.SRulesApply, ruleNames, pi.Name))
eventsInfo = append(eventsInfo,
event.NewEvent(policyKind, "", pi.Name, event.PolicyApplied, event.SPolicyApply, pi.RName))
glog.V(3).Infof("Success events info prepared for %s/%s and %s/%s\n", policyKind, pi.Name, pi.RKind, pi.RName)
glog.V(3).Infof("Success event info prepared for %s/%s\n", pi.RKind, pi.RName)
}
return eventsInfo
}