func()

in pkg/webhook/cert.go [129:154]


func (s *CertService) updateWebHookCABundle(
	ctx context.Context,
	webHookName string,
	caBundle []byte,
) error {
	webHook := &admissionregistrationv1.ValidatingWebhookConfiguration{}

	err := s.clientReader.Get(ctx, ctrlClient.ObjectKey{Name: webHookName}, webHook)
	if err != nil {
		return fmt.Errorf("failed to get validation webHook: %w", err)
	}

	if len(webHook.Webhooks) == 0 {
		return nil
	}

	for i := range webHook.Webhooks {
		webHook.Webhooks[i].ClientConfig.CABundle = caBundle
	}

	if err = s.clientWriter.Update(ctx, webHook); err != nil {
		return fmt.Errorf("failed to update validation webHook caBundle: %w", err)
	}

	return nil
}