func()

in pkg/webhook/nexusrepository_webhook.go [71:97]


func (*NexusRepositoryValidationWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error {
	log := ctrl.LoggerFrom(ctx)

	log.Info("Validate update")

	oldNexusRepository, ok := oldObj.(*nexusApi.NexusRepository)
	if !ok {
		log.Info("The wrong object given, skipping validation")

		return nil
	}

	updatedNexusRepository, ok := newObj.(*nexusApi.NexusRepository)
	if !ok {
		log.Info("The wrong object given, skipping validation")

		return nil
	}

	if err := validateUpdate(&oldNexusRepository.Spec, &updatedNexusRepository.Spec); err != nil {
		return apierrors.NewBadRequest(
			fmt.Errorf("object NexusRepository %s is invalid: %w", updatedNexusRepository.Name, err).Error(),
		)
	}

	return nil
}