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
e48b6f3d
Commit
e48b6f3d
authored
Dec 04, 2017
by
George Kudrayvtsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separates validation per-runtime.
parent
234ce8da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
validation.go
pkg/proxy/apis/kubeproxyconfig/validation/validation.go
+23
-8
validation_test.go
pkg/proxy/apis/kubeproxyconfig/validation/validation_test.go
+1
-1
No files found.
pkg/proxy/apis/kubeproxyconfig/validation/validation.go
View file @
e48b6f3d
...
...
@@ -142,28 +142,43 @@ func validateKubeProxyConntrackConfiguration(config kubeproxyconfig.KubeProxyCon
}
func
validateProxyMode
(
mode
kubeproxyconfig
.
ProxyMode
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
if
runtime
.
GOOS
==
"windows"
{
return
validateProxyModeWindows
(
mode
,
fldPath
)
}
return
validateProxyModeLinux
(
mode
,
fldPath
)
}
func
validateProxyModeLinux
(
mode
kubeproxyconfig
.
ProxyMode
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
switch
mode
{
case
kubeproxyconfig
.
ProxyModeUserspace
:
case
kubeproxyconfig
.
ProxyModeIPTables
:
case
kubeproxyconfig
.
ProxyModeIPVS
:
case
""
:
case
kubeproxyconfig
.
ProxyModeKernelspace
:
if
runtime
.
GOOS
!=
"windows"
{
errMsg
:=
fmt
.
Sprintf
(
"%s is only supported on Windows"
,
string
(
kubeproxyconfig
.
ProxyModeKernelspace
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"ProxyMode"
),
string
(
mode
),
errMsg
))
}
default
:
modes
:=
[]
string
{
string
(
kubeproxyconfig
.
ProxyModeUserspace
),
string
(
kubeproxyconfig
.
ProxyModeIPTables
),
string
(
kubeproxyconfig
.
ProxyModeIPVS
)}
if
runtime
.
GOOS
==
"windows"
{
modes
=
append
(
modes
,
string
(
kubeproxyconfig
.
ProxyModeKernelspace
))
}
errMsg
:=
fmt
.
Sprintf
(
"must be %s or blank (blank means the best-available proxy [currently iptables])"
,
strings
.
Join
(
modes
,
","
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"ProxyMode"
),
string
(
mode
),
errMsg
))
}
return
allErrs
}
func
validateProxyModeWindows
(
mode
kubeproxyconfig
.
ProxyMode
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
switch
mode
{
case
kubeproxyconfig
.
ProxyModeUserspace
:
case
kubeproxyconfig
.
ProxyModeKernelspace
:
default
:
modes
:=
[]
string
{
string
(
kubeproxyconfig
.
ProxyModeUserspace
),
string
(
kubeproxyconfig
.
ProxyModeKernelspace
)}
errMsg
:=
fmt
.
Sprintf
(
"must be %s or blank (blank means the most-available proxy [currently userspace])"
,
strings
.
Join
(
modes
,
","
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"ProxyMode"
),
string
(
mode
),
errMsg
))
}
return
allErrs
}
func
validateClientConnectionConfiguration
(
config
kubeproxyconfig
.
ClientConnectionConfiguration
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateNonnegativeField
(
int64
(
config
.
Burst
),
fldPath
.
Child
(
"Burst"
))
...
)
...
...
pkg/proxy/apis/kubeproxyconfig/validation/validation_test.go
View file @
e48b6f3d
...
...
@@ -510,7 +510,7 @@ func TestValidateProxyMode(t *testing.T) {
}{
{
mode
:
kubeproxyconfig
.
ProxyMode
(
"non-existing"
),
msg
:
"or blank (blank means the
best-available proxy [currently iptables])
"
,
msg
:
"or blank (blank means the"
,
},
}
...
...
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