1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 00:17:13 +00:00
kyverno/pkg/policy/webhookregistration.go

30 lines
879 B
Go
Raw Normal View History

2019-09-04 13:43:12 -07:00
package policy
import (
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/labels"
)
func (pc *PolicyController) removeResourceWebhookConfiguration() error {
var err error
// get all existing policies
policies, err := pc.pLister.List(labels.NewSelector())
if err != nil {
glog.V(4).Infof("failed to list policies: %v", err)
return err
}
if len(policies) == 0 {
glog.V(4).Info("no policies loaded, removing resource webhook configuration if one exists")
return pc.resourceWebhookWatcher.RemoveResourceWebhookConfiguration()
2019-09-04 13:43:12 -07:00
}
glog.V(4).Info("no policies with mutating or validating webhook configurations, remove resource webhook configuration if one exists")
2019-09-04 13:43:12 -07:00
2020-01-24 09:37:12 -08:00
return pc.resourceWebhookWatcher.RemoveResourceWebhookConfiguration()
2019-09-04 13:43:12 -07:00
}
func (pc *PolicyController) registerResourceWebhookConfiguration() {
pc.resourceWebhookWatcher.RegisterResourceWebhook()
2019-09-04 13:43:12 -07:00
}