Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package validation

import (
"net/url"
"strconv"
"strings"

"github.com/gobwas/glob"
"k8s.io/apimachinery/pkg/util/validation/field"
Expand All @@ -17,6 +19,15 @@ func ValidateResourceName(name, pattern string, fldPath *field.Path) ErrorList {
allErrs = append(allErrs, Invalid(fldPath, name, "resource name does not match a valid pattern"))
}

// Make sure the ids are int 64
resourceParts := strings.Split(name, "/")
categoriesCount := len(resourceParts) / 2
for catNumber := 0; catNumber < categoriesCount; catNumber++ {
_, err := strconv.ParseInt(resourceParts[catNumber*2+1], 10, 64)
if err != nil {
allErrs = append(allErrs, Invalid(fldPath, name, "resource ids must be valid int64"))
}
}
return allErrs
}

Expand Down