Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
26b7fbee
Commit
26b7fbee
authored
Mar 06, 2015
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply comments
parent
bb8a4f5e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
validation.go
pkg/util/validation.go
+6
-5
validation_test.go
pkg/util/validation_test.go
+5
-4
No files found.
pkg/util/validation.go
View file @
26b7fbee
...
...
@@ -20,7 +20,11 @@ import (
"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
+
"$"
)
...
...
@@ -35,10 +39,7 @@ func IsValidAnnotationValue(value string) bool {
return
true
}
const
kubeToken
string
=
"[A-Za-z0-9]"
const
extendedKubeToken
string
=
"[-A-Za-z0-9_.]"
const
qualifiedNamePiece
string
=
"("
+
kubeToken
+
extendedKubeToken
+
"*)?"
+
kubeToken
const
QualifiedNameFmt
string
=
"("
+
qualifiedNamePiece
+
"/)?"
+
qualifiedNamePiece
const
QualifiedNameFmt
string
=
"("
+
qualifiedToken
+
"/)?"
+
qualifiedToken
var
qualifiedNameRegexp
=
regexp
.
MustCompile
(
"^"
+
QualifiedNameFmt
+
"$"
)
...
...
pkg/util/validation_test.go
View file @
26b7fbee
...
...
@@ -196,12 +196,9 @@ func TestIsValidLabelValue(t *testing.T) {
"now-with-dashes"
,
"1-starts-with-num"
,
"end-with-num-1"
,
"-starts-with-dash"
,
"ends-with-dash-"
,
".starts.with.dot"
,
"ends.with.dot."
,
"1234"
,
// only num
strings
.
Repeat
(
"a"
,
63
),
// to the limit
""
,
// empty value
}
for
i
:=
range
successCases
{
if
!
IsValidLabelValue
(
successCases
[
i
])
{
...
...
@@ -213,6 +210,10 @@ func TestIsValidLabelValue(t *testing.T) {
"nospecialchars%^=@"
,
"Tama-nui-te-rā.is.Māori.sun"
,
"
\\
backslashes
\\
are
\\
bad"
,
"-starts-with-dash"
,
"ends-with-dash-"
,
".starts.with.dot"
,
"ends.with.dot."
,
strings
.
Repeat
(
"a"
,
64
),
// over the limit
}
for
i
:=
range
errorCases
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment