diff --git a/pkg/webhooks/walruscore/catalog.go b/pkg/webhooks/walruscore/catalog.go index 6e5a03638..90b062202 100644 --- a/pkg/webhooks/walruscore/catalog.go +++ b/pkg/webhooks/walruscore/catalog.go @@ -55,7 +55,6 @@ func (r *CatalogWebhook) validateFilter(obj runtime.Object) (ctrladmission.Warni field.NewPath("spec.filters.includeExpression"), filters.IncludeExpression, err.Error()) } } - if filters.ExcludeExpression != "" { if _, err := regexp.Compile(filters.ExcludeExpression); err != nil { return nil, field.Invalid( diff --git a/pkg/webhooks/walruscore/template.go b/pkg/webhooks/walruscore/template.go index a73012070..717bbb086 100644 --- a/pkg/webhooks/walruscore/template.go +++ b/pkg/webhooks/walruscore/template.go @@ -30,8 +30,11 @@ var _ ctrlwebhook.CustomValidator = (*TemplateWebhook)(nil) func (r *TemplateWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (ctrladmission.Warnings, error) { t := obj.(*walruscore.Template) _, err := sourceurl.ParseURLToSourceURL(t.Spec.VCSRepository.URL) - return nil, field.Invalid( - field.NewPath("spec.vcsRepository.url"), t.Spec.VCSRepository.URL, err.Error()) + if err != nil { + return nil, field.Invalid( + field.NewPath("spec.vcsRepository.url"), t.Spec.VCSRepository.URL, err.Error()) + } + return nil, nil } func (r *TemplateWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (ctrladmission.Warnings, error) {