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
ba45a3f7
Commit
ba45a3f7
authored
Sep 22, 2016
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disallow user to update loadbalancerSourceRanges
parent
87b40782
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
validation.go
pkg/api/validation/validation.go
+3
-0
validation_test.go
pkg/api/validation/validation_test.go
+19
-0
No files found.
pkg/api/validation/validation.go
View file @
ba45a3f7
...
@@ -2568,6 +2568,9 @@ func ValidateServiceUpdate(service, oldService *api.Service) field.ErrorList {
...
@@ -2568,6 +2568,9 @@ func ValidateServiceUpdate(service, oldService *api.Service) field.ErrorList {
allErrs
=
append
(
allErrs
,
ValidateImmutableField
(
service
.
Spec
.
ClusterIP
,
oldService
.
Spec
.
ClusterIP
,
field
.
NewPath
(
"spec"
,
"clusterIP"
))
...
)
allErrs
=
append
(
allErrs
,
ValidateImmutableField
(
service
.
Spec
.
ClusterIP
,
oldService
.
Spec
.
ClusterIP
,
field
.
NewPath
(
"spec"
,
"clusterIP"
))
...
)
}
}
// TODO(freehan): allow user to update loadbalancerSourceRanges
allErrs
=
append
(
allErrs
,
ValidateImmutableField
(
service
.
Spec
.
LoadBalancerSourceRanges
,
oldService
.
Spec
.
LoadBalancerSourceRanges
,
field
.
NewPath
(
"spec"
,
"loadBalancerSourceRanges"
))
...
)
allErrs
=
append
(
allErrs
,
ValidateService
(
service
)
...
)
allErrs
=
append
(
allErrs
,
ValidateService
(
service
)
...
)
return
allErrs
return
allErrs
}
}
...
...
pkg/api/validation/validation_test.go
View file @
ba45a3f7
...
@@ -6388,6 +6388,25 @@ func TestValidateServiceUpdate(t *testing.T) {
...
@@ -6388,6 +6388,25 @@ func TestValidateServiceUpdate(t *testing.T) {
},
},
numErrs
:
0
,
numErrs
:
0
,
},
},
{
name
:
"add loadBalancerSourceRanges"
,
tweakSvc
:
func
(
oldSvc
,
newSvc
*
api
.
Service
)
{
oldSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.0.0.0/8"
}
},
numErrs
:
1
,
},
{
name
:
"update loadBalancerSourceRanges"
,
tweakSvc
:
func
(
oldSvc
,
newSvc
*
api
.
Service
)
{
oldSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
oldSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.0.0.0/8"
}
newSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.180.0.0/16"
}
},
numErrs
:
1
,
},
}
}
for
_
,
tc
:=
range
testCases
{
for
_
,
tc
:=
range
testCases
{
...
...
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