in reconcilers/reconciler.go [320:342]
func updateMutatingWebhookConfig(ctx context.Context, clientset kubernetes.Interface, isKubeSystemNamespaceBlocked bool, data []byte) *error {
logger := log.MustGetLogger(ctx)
client := clientset.AdmissionregistrationV1().MutatingWebhookConfigurations()
webhook, getErr := client.Get(ctx, utils.WebhookConfigName(), metav1.GetOptions{})
if getErr != nil {
logger.Infof(ctx, "fail to get mutating webhook config %s. error: %s", utils.WebhookConfigName(), getErr)
return &getErr
}
webhookFromCm, readErr := getMutatingWebhookConfigFromConfigmap(ctx, clientset, data, isKubeSystemNamespaceBlocked)
if readErr != nil {
logger.Infof(ctx, "fail to get mutating webhook config from configmap. error: %s", *readErr)
return readErr
}
webhook.ObjectMeta.Labels = webhookFromCm.ObjectMeta.Labels
webhook.Webhooks = webhookFromCm.Webhooks
logger.Debugf(ctx, "webhook before update: %v", webhook)
_, updateErr := client.Update(ctx, webhook, metav1.UpdateOptions{})
if updateErr != nil {
logger.Infof(ctx, "fail to update mutating webhook config %s. error: %s", utils.WebhookConfigName(), updateErr)
return &updateErr
}
return nil
}