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
86441233
Commit
86441233
authored
Jun 19, 2015
by
Satnam Singh
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10090 from GoogleCloudPlatform/revert-10083-revert-9688-validate_pod_spec
Revert "Revert "Validate service account name in pod spec""
parents
d9dabd74
0f70095f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
validation.go
pkg/api/validation/validation.go
+5
-0
validation_test.go
pkg/api/validation/validation_test.go
+7
-0
No files found.
pkg/api/validation/validation.go
View file @
86441233
...
...
@@ -963,6 +963,11 @@ func ValidatePodSpec(spec *api.PodSpec) errs.ValidationErrorList {
allErrs
=
append
(
allErrs
,
ValidateLabels
(
spec
.
NodeSelector
,
"nodeSelector"
)
...
)
allErrs
=
append
(
allErrs
,
validateHostNetwork
(
spec
.
HostNetwork
,
spec
.
Containers
)
.
Prefix
(
"hostNetwork"
)
...
)
allErrs
=
append
(
allErrs
,
validateImagePullSecrets
(
spec
.
ImagePullSecrets
)
.
Prefix
(
"imagePullSecrets"
)
...
)
if
len
(
spec
.
ServiceAccount
)
>
0
{
if
ok
,
msg
:=
ValidateServiceAccountName
(
spec
.
ServiceAccount
,
false
);
!
ok
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"serviceAccount"
,
spec
.
ServiceAccount
,
msg
))
}
}
if
spec
.
ActiveDeadlineSeconds
!=
nil
{
if
*
spec
.
ActiveDeadlineSeconds
<=
0
{
...
...
pkg/api/validation/validation_test.go
View file @
86441233
...
...
@@ -1052,6 +1052,7 @@ func TestValidatePodSpec(t *testing.T) {
NodeName
:
"foobar"
,
DNSPolicy
:
api
.
DNSClusterFirst
,
ActiveDeadlineSeconds
:
&
activeDeadlineSeconds
,
ServiceAccount
:
"acct"
,
},
{
// Populate HostNetwork.
Containers
:
[]
api
.
Container
{
...
...
@@ -1092,6 +1093,12 @@ func TestValidatePodSpec(t *testing.T) {
RestartPolicy
:
api
.
RestartPolicyAlways
,
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
},
"bad service account name"
:
{
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
ServiceAccount
:
"invalidName"
,
},
"bad restart policy"
:
{
RestartPolicy
:
"UnknowPolicy"
,
DNSPolicy
:
api
.
DNSClusterFirst
,
...
...
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