1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 07:26:55 +00:00
kyverno/pkg/policy/webhookregistration.go
shivkumar dudhani d327309d72 refactor logging
2020-03-17 16:25:34 -07:00

29 lines
868 B
Go

package policy
import (
"k8s.io/apimachinery/pkg/labels"
)
func (pc *PolicyController) removeResourceWebhookConfiguration() error {
logger := pc.log
var err error
// get all existing policies
policies, err := pc.pLister.List(labels.NewSelector())
if err != nil {
logger.Error(err, "failed to list policies")
return err
}
if len(policies) == 0 {
logger.V(4).Info("no policies loaded, removing resource webhook configuration if one exists")
return pc.resourceWebhookWatcher.RemoveResourceWebhookConfiguration()
}
logger.V(4).Info("no policies with mutating or validating webhook configurations, remove resource webhook configuration if one exists")
return pc.resourceWebhookWatcher.RemoveResourceWebhookConfiguration()
}
func (pc *PolicyController) registerResourceWebhookConfiguration() {
pc.resourceWebhookWatcher.RegisterResourceWebhook()
}