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
8829efae
Unverified
Commit
8829efae
authored
May 24, 2019
by
Tobias Hintze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow trailing dot for service.spec.externalName
parent
da31c50d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
validation.go
pkg/apis/core/validation/validation.go
+5
-2
validation_test.go
pkg/apis/core/validation/validation_test.go
+9
-0
No files found.
pkg/apis/core/validation/validation.go
View file @
8829efae
...
@@ -3692,8 +3692,11 @@ func ValidateService(service *core.Service) field.ErrorList {
...
@@ -3692,8 +3692,11 @@ func ValidateService(service *core.Service) field.ErrorList {
if
service
.
Spec
.
ClusterIP
!=
""
{
if
service
.
Spec
.
ClusterIP
!=
""
{
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
specPath
.
Child
(
"clusterIP"
),
"must be empty for ExternalName services"
))
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
specPath
.
Child
(
"clusterIP"
),
"must be empty for ExternalName services"
))
}
}
if
len
(
service
.
Spec
.
ExternalName
)
>
0
{
allErrs
=
append
(
allErrs
,
ValidateDNS1123Subdomain
(
service
.
Spec
.
ExternalName
,
specPath
.
Child
(
"externalName"
))
...
)
// The value (a CNAME) may have a trailing dot to denote it as fully qualified
cname
:=
strings
.
TrimSuffix
(
service
.
Spec
.
ExternalName
,
"."
)
if
len
(
cname
)
>
0
{
allErrs
=
append
(
allErrs
,
ValidateDNS1123Subdomain
(
cname
,
specPath
.
Child
(
"externalName"
))
...
)
}
else
{
}
else
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
specPath
.
Child
(
"externalName"
),
""
))
allErrs
=
append
(
allErrs
,
field
.
Required
(
specPath
.
Child
(
"externalName"
),
""
))
}
}
...
...
pkg/apis/core/validation/validation_test.go
View file @
8829efae
...
@@ -9307,6 +9307,15 @@ func TestValidateService(t *testing.T) {
...
@@ -9307,6 +9307,15 @@ func TestValidateService(t *testing.T) {
numErrs
:
0
,
numErrs
:
0
,
},
},
{
{
name
:
"valid ExternalName (trailing dot)"
,
tweakSvc
:
func
(
s
*
core
.
Service
)
{
s
.
Spec
.
Type
=
core
.
ServiceTypeExternalName
s
.
Spec
.
ClusterIP
=
""
s
.
Spec
.
ExternalName
=
"foo.bar.example.com."
},
numErrs
:
0
,
},
{
name
:
"invalid ExternalName clusterIP (valid IP)"
,
name
:
"invalid ExternalName clusterIP (valid IP)"
,
tweakSvc
:
func
(
s
*
core
.
Service
)
{
tweakSvc
:
func
(
s
*
core
.
Service
)
{
s
.
Spec
.
Type
=
core
.
ServiceTypeExternalName
s
.
Spec
.
Type
=
core
.
ServiceTypeExternalName
...
...
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