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
3155cad4
Commit
3155cad4
authored
Nov 04, 2014
by
bgrant0607
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2169 from bgrant0607/config
Update api/validation service validation with service fields moved by #2086
parents
fc0dab63
535785e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
17 deletions
+25
-17
validation.go
pkg/api/validation/validation.go
+3
-3
validation_test.go
pkg/api/validation/validation_test.go
+22
-14
No files found.
pkg/api/validation/validation.go
View file @
3155cad4
...
@@ -408,14 +408,14 @@ func ValidateService(service *api.Service, lister ServiceLister, ctx api.Context
...
@@ -408,14 +408,14 @@ func ValidateService(service *api.Service, lister ServiceLister, ctx api.Context
if
labels
.
Set
(
service
.
Spec
.
Selector
)
.
AsSelector
()
.
Empty
()
{
if
labels
.
Set
(
service
.
Spec
.
Selector
)
.
AsSelector
()
.
Empty
()
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"spec.selector"
,
service
.
Spec
.
Selector
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"spec.selector"
,
service
.
Spec
.
Selector
))
}
}
if
service
.
CreateExternalLoadBalancer
{
if
service
.
Spec
.
CreateExternalLoadBalancer
{
services
,
err
:=
lister
.
ListServices
(
ctx
)
services
,
err
:=
lister
.
ListServices
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
allErrs
=
append
(
allErrs
,
errs
.
NewInternalError
(
err
))
allErrs
=
append
(
allErrs
,
errs
.
NewInternalError
(
err
))
}
else
{
}
else
{
for
i
:=
range
services
.
Items
{
for
i
:=
range
services
.
Items
{
if
services
.
Items
[
i
]
.
CreateExternalLoadBalancer
&&
services
.
Items
[
i
]
.
Port
==
service
.
Port
{
if
services
.
Items
[
i
]
.
Spec
.
CreateExternalLoadBalancer
&&
services
.
Items
[
i
]
.
Spec
.
Port
==
service
.
Spec
.
Port
{
allErrs
=
append
(
allErrs
,
errs
.
NewConflict
(
"service"
,
service
.
Namespace
,
fmt
.
Errorf
(
"Port: %d is already in use"
,
service
.
Port
)))
allErrs
=
append
(
allErrs
,
errs
.
NewConflict
(
"service"
,
service
.
Namespace
,
fmt
.
Errorf
(
"Port: %d is already in use"
,
service
.
Spec
.
Port
)))
break
break
}
}
}
}
...
...
pkg/api/validation/validation_test.go
View file @
3155cad4
...
@@ -753,13 +753,15 @@ func TestValidateService(t *testing.T) {
...
@@ -753,13 +753,15 @@ func TestValidateService(t *testing.T) {
name
:
"invalid port in use"
,
name
:
"invalid port in use"
,
svc
:
api
.
Service
{
svc
:
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
Port
:
80
,
Spec
:
api
.
ServiceSpec
{
CreateExternalLoadBalancer
:
true
,
Port
:
80
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
CreateExternalLoadBalancer
:
true
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
},
existing
:
api
.
ServiceList
{
existing
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
Port
:
80
,
CreateExternalLoadBalancer
:
true
},
{
Spec
:
api
.
ServiceSpec
{
Port
:
80
,
CreateExternalLoadBalancer
:
true
}
},
},
},
},
},
numErrs
:
1
,
numErrs
:
1
,
...
@@ -768,13 +770,15 @@ func TestValidateService(t *testing.T) {
...
@@ -768,13 +770,15 @@ func TestValidateService(t *testing.T) {
name
:
"same port in use, but not external"
,
name
:
"same port in use, but not external"
,
svc
:
api
.
Service
{
svc
:
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
Port
:
80
,
Spec
:
api
.
ServiceSpec
{
CreateExternalLoadBalancer
:
true
,
Port
:
80
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
CreateExternalLoadBalancer
:
true
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
},
existing
:
api
.
ServiceList
{
existing
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
Port
:
80
},
{
Spec
:
api
.
ServiceSpec
{
Port
:
80
}
},
},
},
},
},
numErrs
:
0
,
numErrs
:
0
,
...
@@ -783,12 +787,14 @@ func TestValidateService(t *testing.T) {
...
@@ -783,12 +787,14 @@ func TestValidateService(t *testing.T) {
name
:
"same port in use, but not external on input"
,
name
:
"same port in use, but not external on input"
,
svc
:
api
.
Service
{
svc
:
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
Port
:
80
,
Spec
:
api
.
ServiceSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Port
:
80
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
},
existing
:
api
.
ServiceList
{
existing
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
Port
:
80
,
CreateExternalLoadBalancer
:
true
},
{
Spec
:
api
.
ServiceSpec
{
Port
:
80
,
CreateExternalLoadBalancer
:
true
}
},
},
},
},
},
numErrs
:
0
,
numErrs
:
0
,
...
@@ -797,12 +803,14 @@ func TestValidateService(t *testing.T) {
...
@@ -797,12 +803,14 @@ func TestValidateService(t *testing.T) {
name
:
"same port in use, but neither external"
,
name
:
"same port in use, but neither external"
,
svc
:
api
.
Service
{
svc
:
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc123"
,
Namespace
:
api
.
NamespaceDefault
},
Port
:
80
,
Spec
:
api
.
ServiceSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Port
:
80
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
},
existing
:
api
.
ServiceList
{
existing
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
Port
:
80
},
{
Spec
:
api
.
ServiceSpec
{
Port
:
80
}
},
},
},
},
},
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