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
772069fe
Commit
772069fe
authored
Mar 22, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23176 from pmorie/unique-volume-mount
Auto commit by PR queue bot
parents
a1cd7311
24aade64
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
validation.go
pkg/api/validation/validation.go
+5
-0
validation_test.go
pkg/api/validation/validation_test.go
+3
-2
No files found.
pkg/api/validation/validation.go
View file @
772069fe
...
@@ -1107,6 +1107,7 @@ func validateSecretKeySelector(s *api.SecretKeySelector, fldPath *field.Path) fi
...
@@ -1107,6 +1107,7 @@ func validateSecretKeySelector(s *api.SecretKeySelector, fldPath *field.Path) fi
func
validateVolumeMounts
(
mounts
[]
api
.
VolumeMount
,
volumes
sets
.
String
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
func
validateVolumeMounts
(
mounts
[]
api
.
VolumeMount
,
volumes
sets
.
String
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
allErrs
:=
field
.
ErrorList
{}
mountpoints
:=
sets
.
NewString
()
for
i
,
mnt
:=
range
mounts
{
for
i
,
mnt
:=
range
mounts
{
idxPath
:=
fldPath
.
Index
(
i
)
idxPath
:=
fldPath
.
Index
(
i
)
...
@@ -1120,6 +1121,10 @@ func validateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath
...
@@ -1120,6 +1121,10 @@ func validateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath
}
else
if
strings
.
Contains
(
mnt
.
MountPath
,
":"
)
{
}
else
if
strings
.
Contains
(
mnt
.
MountPath
,
":"
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
idxPath
.
Child
(
"mountPath"
),
mnt
.
MountPath
,
"must not contain ':'"
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
idxPath
.
Child
(
"mountPath"
),
mnt
.
MountPath
,
"must not contain ':'"
))
}
}
if
mountpoints
.
Has
(
mnt
.
MountPath
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
idxPath
.
Child
(
"mountPath"
),
mnt
.
MountPath
,
"must be unique"
))
}
mountpoints
.
Insert
(
mnt
.
MountPath
)
}
}
return
allErrs
return
allErrs
}
}
...
...
pkg/api/validation/validation_test.go
View file @
772069fe
...
@@ -1124,8 +1124,8 @@ func TestValidateVolumeMounts(t *testing.T) {
...
@@ -1124,8 +1124,8 @@ func TestValidateVolumeMounts(t *testing.T) {
successCase
:=
[]
api
.
VolumeMount
{
successCase
:=
[]
api
.
VolumeMount
{
{
Name
:
"abc"
,
MountPath
:
"/foo"
},
{
Name
:
"abc"
,
MountPath
:
"/foo"
},
{
Name
:
"123"
,
MountPath
:
"/
foo
"
},
{
Name
:
"123"
,
MountPath
:
"/
bar
"
},
{
Name
:
"abc-123"
,
MountPath
:
"/ba
r
"
},
{
Name
:
"abc-123"
,
MountPath
:
"/ba
z
"
},
}
}
if
errs
:=
validateVolumeMounts
(
successCase
,
volumes
,
field
.
NewPath
(
"field"
));
len
(
errs
)
!=
0
{
if
errs
:=
validateVolumeMounts
(
successCase
,
volumes
,
field
.
NewPath
(
"field"
));
len
(
errs
)
!=
0
{
t
.
Errorf
(
"expected success: %v"
,
errs
)
t
.
Errorf
(
"expected success: %v"
,
errs
)
...
@@ -1136,6 +1136,7 @@ func TestValidateVolumeMounts(t *testing.T) {
...
@@ -1136,6 +1136,7 @@ func TestValidateVolumeMounts(t *testing.T) {
"name not found"
:
{{
Name
:
""
,
MountPath
:
"/foo"
}},
"name not found"
:
{{
Name
:
""
,
MountPath
:
"/foo"
}},
"empty mountpath"
:
{{
Name
:
"abc"
,
MountPath
:
""
}},
"empty mountpath"
:
{{
Name
:
"abc"
,
MountPath
:
""
}},
"colon mountpath"
:
{{
Name
:
"abc"
,
MountPath
:
"foo:bar"
}},
"colon mountpath"
:
{{
Name
:
"abc"
,
MountPath
:
"foo:bar"
}},
"mountpath collision"
:
{{
Name
:
"foo"
,
MountPath
:
"/path/a"
},
{
Name
:
"bar"
,
MountPath
:
"/path/a"
}},
}
}
for
k
,
v
:=
range
errorCases
{
for
k
,
v
:=
range
errorCases
{
if
errs
:=
validateVolumeMounts
(
v
,
volumes
,
field
.
NewPath
(
"field"
));
len
(
errs
)
==
0
{
if
errs
:=
validateVolumeMounts
(
v
,
volumes
,
field
.
NewPath
(
"field"
));
len
(
errs
)
==
0
{
...
...
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