Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix: panic on template webhook validation
Browse files Browse the repository at this point in the history
Signed-off-by: thxCode <[email protected]>
  • Loading branch information
thxCode committed Apr 18, 2024
1 parent 9999ec5 commit 8783c19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion pkg/webhooks/walruscore/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 5 additions & 2 deletions pkg/webhooks/walruscore/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8783c19

Please sign in to comment.