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
81aab06e
Commit
81aab06e
authored
May 12, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7486 from feihujiang/master
Duplicate service port name can't be validated
parents
a8129fce
4bb594b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
validation.go
pkg/api/validation/validation.go
+2
-0
validation_test.go
pkg/api/validation/validation_test.go
+3
-3
No files found.
pkg/api/validation/validation.go
View file @
81aab06e
...
@@ -1028,6 +1028,8 @@ func validateServicePort(sp *api.ServicePort, requireName bool, allNames *util.S
...
@@ -1028,6 +1028,8 @@ func validateServicePort(sp *api.ServicePort, requireName bool, allNames *util.S
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
sp
.
Name
,
dns1123LabelErrorMsg
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
sp
.
Name
,
dns1123LabelErrorMsg
))
}
else
if
allNames
.
Has
(
sp
.
Name
)
{
}
else
if
allNames
.
Has
(
sp
.
Name
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldDuplicate
(
"name"
,
sp
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldDuplicate
(
"name"
,
sp
.
Name
))
}
else
{
allNames
.
Insert
(
sp
.
Name
)
}
}
}
}
...
...
pkg/api/validation/validation_test.go
View file @
81aab06e
...
@@ -1682,7 +1682,7 @@ func TestValidateService(t *testing.T) {
...
@@ -1682,7 +1682,7 @@ func TestValidateService(t *testing.T) {
name
:
"dup port name"
,
name
:
"dup port name"
,
tweakSvc
:
func
(
s
*
api
.
Service
)
{
tweakSvc
:
func
(
s
*
api
.
Service
)
{
s
.
Spec
.
Ports
[
0
]
.
Name
=
"p"
s
.
Spec
.
Ports
[
0
]
.
Name
=
"p"
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"p"
,
Port
:
12345
})
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"p"
,
Port
:
12345
,
Protocol
:
"TCP"
})
},
},
numErrs
:
1
,
numErrs
:
1
,
},
},
...
@@ -1698,7 +1698,7 @@ func TestValidateService(t *testing.T) {
...
@@ -1698,7 +1698,7 @@ func TestValidateService(t *testing.T) {
name
:
"invalid load balancer protocol 2"
,
name
:
"invalid load balancer protocol 2"
,
tweakSvc
:
func
(
s
*
api
.
Service
)
{
tweakSvc
:
func
(
s
*
api
.
Service
)
{
s
.
Spec
.
CreateExternalLoadBalancer
=
true
s
.
Spec
.
CreateExternalLoadBalancer
=
true
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"
p
"
,
Port
:
12345
,
Protocol
:
"UDP"
})
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"
q
"
,
Port
:
12345
,
Protocol
:
"UDP"
})
},
},
numErrs
:
1
,
numErrs
:
1
,
},
},
...
@@ -1750,7 +1750,7 @@ func TestValidateService(t *testing.T) {
...
@@ -1750,7 +1750,7 @@ func TestValidateService(t *testing.T) {
name
:
"valid external load balancer 2 ports"
,
name
:
"valid external load balancer 2 ports"
,
tweakSvc
:
func
(
s
*
api
.
Service
)
{
tweakSvc
:
func
(
s
*
api
.
Service
)
{
s
.
Spec
.
CreateExternalLoadBalancer
=
true
s
.
Spec
.
CreateExternalLoadBalancer
=
true
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"
p
"
,
Port
:
12345
,
Protocol
:
"TCP"
})
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"
q
"
,
Port
:
12345
,
Protocol
:
"TCP"
})
},
},
numErrs
:
0
,
numErrs
:
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