mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 15:38:06 +00:00
Add max length for secret key names
Max length for secret key names must be DNS1123 compliant (253)
This commit is contained in:
@@ -129,5 +129,10 @@ var invalidStartEndChars = regexp.MustCompile("(^[^a-zA-Z0-9-._]+|[^a-zA-Z0-9-._
|
|||||||
func createValidSecretDataName(value string) string {
|
func createValidSecretDataName(value string) string {
|
||||||
result := invalidStartEndChars.ReplaceAllString(value, "")
|
result := invalidStartEndChars.ReplaceAllString(value, "")
|
||||||
result = invalidDataChars.ReplaceAllString(result, "-")
|
result = invalidDataChars.ReplaceAllString(result, "-")
|
||||||
|
|
||||||
|
if len(result) > kubeValidate.DNS1123SubdomainMaxLength {
|
||||||
|
result = result[0:kubeValidate.DNS1123SubdomainMaxLength]
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@@ -129,7 +129,7 @@ func TestBuildKubernetesSecretFixesInvalidLabels(t *testing.T) {
|
|||||||
Value: "value1",
|
Value: "value1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Label: strings.Repeat("x", kubeValidate.LabelValueMaxLength+1),
|
Label: strings.Repeat("x", kubeValidate.DNS1123SubdomainMaxLength+1),
|
||||||
Value: "name exceeds max length",
|
Value: "name exceeds max length",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user