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
83ac613b
Commit
83ac613b
authored
Jan 11, 2017
by
Dan Winship
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up existing NetworkPolicy validation
Paths were wrong for most errors. Field name was wrong for namespaceSelector.
parent
4f8f6006
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
validation.go
pkg/apis/extensions/validation/validation.go
+12
-13
No files found.
pkg/apis/extensions/validation/validation.go
View file @
83ac613b
...
@@ -828,26 +828,25 @@ func ValidateNetworkPolicySpec(spec *extensions.NetworkPolicySpec, fldPath *fiel
...
@@ -828,26 +828,25 @@ func ValidateNetworkPolicySpec(spec *extensions.NetworkPolicySpec, fldPath *fiel
allErrs
=
append
(
allErrs
,
unversionedvalidation
.
ValidateLabelSelector
(
&
spec
.
PodSelector
,
fldPath
.
Child
(
"podSelector"
))
...
)
allErrs
=
append
(
allErrs
,
unversionedvalidation
.
ValidateLabelSelector
(
&
spec
.
PodSelector
,
fldPath
.
Child
(
"podSelector"
))
...
)
// Validate ingress rules.
// Validate ingress rules.
for
_
,
i
:=
range
spec
.
Ingress
{
for
i
,
ingress
:=
range
spec
.
Ingress
{
ingressPath
:=
fldPath
.
Child
(
"ingress"
)
.
Index
(
i
)
// TODO: Update From to be a pointer to slice as soon as auto-generation supports it.
// TODO: Update From to be a pointer to slice as soon as auto-generation supports it.
for
_
,
f
:=
range
i
.
From
{
for
i
,
from
:=
range
ingress
.
From
{
fromPath
:=
ingressPath
.
Child
(
"from"
)
.
Index
(
i
)
numFroms
:=
0
numFroms
:=
0
if
f
.
PodSelector
!=
nil
{
if
f
rom
.
PodSelector
!=
nil
{
numFroms
++
numFroms
++
allErrs
=
append
(
allErrs
,
unversionedvalidation
.
ValidateLabelSelector
(
f
.
PodSelector
,
fld
Path
.
Child
(
"podSelector"
))
...
)
allErrs
=
append
(
allErrs
,
unversionedvalidation
.
ValidateLabelSelector
(
f
rom
.
PodSelector
,
from
Path
.
Child
(
"podSelector"
))
...
)
}
}
if
f
.
NamespaceSelector
!=
nil
{
if
from
.
NamespaceSelector
!=
nil
{
if
numFroms
>
0
{
numFroms
++
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
fldPath
,
"may not specify more than 1 from type"
))
allErrs
=
append
(
allErrs
,
unversionedvalidation
.
ValidateLabelSelector
(
from
.
NamespaceSelector
,
fromPath
.
Child
(
"namespaceSelector"
))
...
)
}
else
{
numFroms
++
allErrs
=
append
(
allErrs
,
unversionedvalidation
.
ValidateLabelSelector
(
f
.
NamespaceSelector
,
fldPath
.
Child
(
"namespaces"
))
...
)
}
}
}
if
numFroms
==
0
{
if
numFroms
==
0
{
// At least one of PodSelector and NamespaceSelector must be defined.
allErrs
=
append
(
allErrs
,
field
.
Required
(
fromPath
,
"must specify a from type"
))
allErrs
=
append
(
allErrs
,
field
.
Required
(
fldPath
,
"must specify a from type"
))
}
else
if
numFroms
>
1
{
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
fromPath
,
"may not specify more than 1 from type"
))
}
}
}
}
}
}
...
...
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