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
6e8f5fea
Commit
6e8f5fea
authored
Jan 05, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix validation for BoundPods to allow defaults
Thunking to Manifest makes a copy of the input, which is not useful for defaulting.
parent
33fcef6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
validation.go
pkg/api/validation/validation.go
+17
-18
No files found.
pkg/api/validation/validation.go
View file @
6e8f5fea
...
@@ -370,8 +370,12 @@ func ValidatePod(pod *api.Pod) errs.ValidationErrorList {
...
@@ -370,8 +370,12 @@ func ValidatePod(pod *api.Pod) errs.ValidationErrorList {
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
if
len
(
pod
.
Name
)
==
0
{
if
len
(
pod
.
Name
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"name"
,
pod
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"name"
,
pod
.
Name
))
}
else
if
!
util
.
IsDNSSubdomain
(
pod
.
Name
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
pod
.
Name
,
""
))
}
}
if
!
util
.
IsDNSSubdomain
(
pod
.
Namespace
)
{
if
len
(
pod
.
Namespace
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"namespace"
,
pod
.
Namespace
))
}
else
if
!
util
.
IsDNSSubdomain
(
pod
.
Namespace
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
pod
.
Namespace
,
""
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
pod
.
Namespace
,
""
))
}
}
allErrs
=
append
(
allErrs
,
ValidatePodSpec
(
&
pod
.
Spec
)
.
Prefix
(
"spec"
)
...
)
allErrs
=
append
(
allErrs
,
ValidatePodSpec
(
&
pod
.
Spec
)
.
Prefix
(
"spec"
)
...
)
...
@@ -549,25 +553,20 @@ func ValidateReadOnlyPersistentDisks(volumes []api.Volume) errs.ValidationErrorL
...
@@ -549,25 +553,20 @@ func ValidateReadOnlyPersistentDisks(volumes []api.Volume) errs.ValidationErrorL
}
}
// ValidateBoundPod tests if required fields on a bound pod are set.
// ValidateBoundPod tests if required fields on a bound pod are set.
func
ValidateBoundPod
(
pod
*
api
.
BoundPod
)
(
errors
[]
error
)
{
func
ValidateBoundPod
(
pod
*
api
.
BoundPod
)
errs
.
ValidationErrorList
{
if
!
util
.
IsDNSSubdomain
(
pod
.
Name
)
{
allErrs
:=
errs
.
ValidationErrorList
{}
errors
=
append
(
errors
,
errs
.
NewFieldInvalid
(
"name"
,
pod
.
Name
,
""
))
if
len
(
pod
.
Name
)
==
0
{
}
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"name"
,
pod
.
Name
))
if
!
util
.
IsDNSSubdomain
(
pod
.
Namespace
)
{
}
else
if
!
util
.
IsDNSSubdomain
(
pod
.
Name
)
{
errors
=
append
(
errors
,
errs
.
NewFieldInvalid
(
"namespace"
,
pod
.
Namespace
,
""
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
pod
.
Name
,
""
))
}
containerManifest
:=
&
api
.
ContainerManifest
{
Version
:
"v1beta2"
,
ID
:
pod
.
Name
,
UUID
:
pod
.
UID
,
Containers
:
pod
.
Spec
.
Containers
,
Volumes
:
pod
.
Spec
.
Volumes
,
RestartPolicy
:
pod
.
Spec
.
RestartPolicy
,
}
}
if
errs
:=
ValidateManifest
(
containerManifest
);
len
(
errs
)
!=
0
{
if
len
(
pod
.
Name
)
==
0
{
errors
=
append
(
errors
,
errs
...
)
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"namespace"
,
pod
.
Namespace
))
}
else
if
!
util
.
IsDNSSubdomain
(
pod
.
Namespace
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
pod
.
Namespace
,
""
))
}
}
return
errors
allErrs
=
append
(
allErrs
,
ValidatePodSpec
(
&
pod
.
Spec
)
.
Prefix
(
"spec"
)
...
)
return
allErrs
}
}
// ValidateMinion tests if required fields in the minion are set.
// ValidateMinion tests if required fields in the minion are set.
...
...
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