mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
apply comments
This commit is contained in:
parent
bb8a4f5ed3
commit
26b7fbeedf
@ -20,7 +20,11 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const LabelValueFmt string = "[-A-Za-z0-9_.]*"
|
const kubeChar string = "[A-Za-z0-9]"
|
||||||
|
const extendedKubeChar string = "[-A-Za-z0-9_.]"
|
||||||
|
const qualifiedToken string = "(" + kubeChar + extendedKubeChar + "*)?" + kubeChar
|
||||||
|
|
||||||
|
const LabelValueFmt string = "((" + kubeChar + extendedKubeChar + "*)?" + kubeChar + ")?"
|
||||||
|
|
||||||
var labelValueRegexp = regexp.MustCompile("^" + LabelValueFmt + "$")
|
var labelValueRegexp = regexp.MustCompile("^" + LabelValueFmt + "$")
|
||||||
|
|
||||||
@ -35,10 +39,7 @@ func IsValidAnnotationValue(value string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const kubeToken string = "[A-Za-z0-9]"
|
const QualifiedNameFmt string = "(" + qualifiedToken + "/)?" + qualifiedToken
|
||||||
const extendedKubeToken string = "[-A-Za-z0-9_.]"
|
|
||||||
const qualifiedNamePiece string = "(" + kubeToken + extendedKubeToken + "*)?" + kubeToken
|
|
||||||
const QualifiedNameFmt string = "(" + qualifiedNamePiece + "/)?" + qualifiedNamePiece
|
|
||||||
|
|
||||||
var qualifiedNameRegexp = regexp.MustCompile("^" + QualifiedNameFmt + "$")
|
var qualifiedNameRegexp = regexp.MustCompile("^" + QualifiedNameFmt + "$")
|
||||||
|
|
||||||
|
@ -196,12 +196,9 @@ func TestIsValidLabelValue(t *testing.T) {
|
|||||||
"now-with-dashes",
|
"now-with-dashes",
|
||||||
"1-starts-with-num",
|
"1-starts-with-num",
|
||||||
"end-with-num-1",
|
"end-with-num-1",
|
||||||
"-starts-with-dash",
|
|
||||||
"ends-with-dash-",
|
|
||||||
".starts.with.dot",
|
|
||||||
"ends.with.dot.",
|
|
||||||
"1234", // only num
|
"1234", // only num
|
||||||
strings.Repeat("a", 63), // to the limit
|
strings.Repeat("a", 63), // to the limit
|
||||||
|
"", // empty value
|
||||||
}
|
}
|
||||||
for i := range successCases {
|
for i := range successCases {
|
||||||
if !IsValidLabelValue(successCases[i]) {
|
if !IsValidLabelValue(successCases[i]) {
|
||||||
@ -213,6 +210,10 @@ func TestIsValidLabelValue(t *testing.T) {
|
|||||||
"nospecialchars%^=@",
|
"nospecialchars%^=@",
|
||||||
"Tama-nui-te-rā.is.Māori.sun",
|
"Tama-nui-te-rā.is.Māori.sun",
|
||||||
"\\backslashes\\are\\bad",
|
"\\backslashes\\are\\bad",
|
||||||
|
"-starts-with-dash",
|
||||||
|
"ends-with-dash-",
|
||||||
|
".starts.with.dot",
|
||||||
|
"ends.with.dot.",
|
||||||
strings.Repeat("a", 64), // over the limit
|
strings.Repeat("a", 64), // over the limit
|
||||||
}
|
}
|
||||||
for i := range errorCases {
|
for i := range errorCases {
|
||||||
|
Loading…
Reference in New Issue
Block a user