mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-21 23:18:06 +00:00
Adjust regex to support _
and .
and trim them
Now secret names can also contain `_` and `.` and they will be trimmed from start and end of string to be DNS1123 compliant
This commit is contained in:
@@ -97,7 +97,7 @@ func formatSecretName(value string) string {
|
||||
return createValidSecretName(value)
|
||||
}
|
||||
|
||||
var invalidDNS1123Chars = regexp.MustCompile("[^a-zA-Z0-9-]+")
|
||||
var invalidDNS1123Chars = regexp.MustCompile("[^a-zA-Z0-9-_.]+")
|
||||
|
||||
func createValidSecretName(value string) string {
|
||||
result := invalidDNS1123Chars.ReplaceAllString(value, "-")
|
||||
@@ -107,5 +107,5 @@ func createValidSecretName(value string) string {
|
||||
}
|
||||
|
||||
// first and last character MUST be alphanumeric
|
||||
return strings.Trim(result, "-")
|
||||
return strings.Trim(result, "-._")
|
||||
}
|
||||
|
Reference in New Issue
Block a user