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
d52cef11
Commit
d52cef11
authored
Jun 01, 2015
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add v1 tests to hack/test-go; let default value of Container.SecurityContext to be nil
parent
9740c7c3
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
165 additions
and
5 deletions
+165
-5
integration.go
cmd/integration/integration.go
+17
-0
v1-controller.json
cmd/integration/v1-controller.json
+24
-0
examples_test.go
examples/examples_test.go
+1
-0
test-go.sh
hack/test-go.sh
+1
-1
defaults.go
pkg/api/v1beta3/defaults.go
+3
-0
invalidPod.yaml
pkg/api/validation/testdata/v1/invalidPod.yaml
+11
-0
invalidPod1.json
pkg/api/validation/testdata/v1/invalidPod1.json
+19
-0
invalidPod2.json
pkg/api/validation/testdata/v1/invalidPod2.json
+35
-0
invalidPod3.json
pkg/api/validation/testdata/v1/invalidPod3.json
+35
-0
validPod.yaml
pkg/api/validation/testdata/v1/validPod.yaml
+16
-0
http_test.go
pkg/kubelet/config/http_test.go
+3
-4
No files found.
cmd/integration/integration.go
View file @
d52cef11
...
...
@@ -623,6 +623,23 @@ func runPatchTest(c *client.Client) {
[]
byte
(
`{"metadata":{"labels":{"$patch":"replace"}}}`
),
},
},
"v1"
:
{
api
.
JSONPatchType
:
{
[]
byte
(
`[{"op":"add","path":"/metadata/labels","value":{"foo":"bar","baz":"qux"}}]`
),
[]
byte
(
`[{"op":"remove","path":"/metadata/labels/foo"}]`
),
[]
byte
(
`[{"op":"remove","path":"/metadata/labels"}]`
),
},
api
.
MergePatchType
:
{
[]
byte
(
`{"metadata":{"labels":{"foo":"bar","baz":"qux"}}}`
),
[]
byte
(
`{"metadata":{"labels":{"foo":null}}}`
),
[]
byte
(
`{"metadata":{"labels":null}}`
),
},
api
.
StrategicMergePatchType
:
{
[]
byte
(
`{"metadata":{"labels":{"foo":"bar","baz":"qux"}}}`
),
[]
byte
(
`{"metadata":{"labels":{"foo":null}}}`
),
[]
byte
(
`{"metadata":{"labels":{"$patch":"replace"}}}`
),
},
},
}
pb
:=
patchBodies
[
c
.
APIVersion
()]
...
...
cmd/integration/v1-controller.json
0 → 100644
View file @
d52cef11
{
"kind"
:
"ReplicationController"
,
"apiVersion"
:
"v1"
,
"metadata"
:
{
"name"
:
"nginx-controller"
,
"labels"
:
{
"name"
:
"nginx"
}
},
"spec"
:
{
"replicas"
:
2
,
"selector"
:
{
"name"
:
"nginx"
},
"template"
:
{
"metadata"
:
{
"labels"
:
{
"name"
:
"nginx"
}
},
"spec"
:
{
"containers"
:
[{
"name"
:
"nginx"
,
"image"
:
"nginx"
,
"ports"
:
[{
"containerPort"
:
80
}]
}]
}
}
}
}
examples/examples_test.go
View file @
d52cef11
...
...
@@ -140,6 +140,7 @@ func TestExampleObjectSchemas(t *testing.T) {
cases
:=
map
[
string
]
map
[
string
]
runtime
.
Object
{
"../cmd/integration"
:
{
"v1beta3-controller"
:
&
api
.
ReplicationController
{},
"v1-controller"
:
&
api
.
ReplicationController
{},
},
"../examples/guestbook"
:
{
"frontend-controller"
:
&
api
.
ReplicationController
{},
...
...
hack/test-go.sh
View file @
d52cef11
...
...
@@ -52,7 +52,7 @@ KUBE_RACE=${KUBE_RACE:-} # use KUBE_RACE="-race" to enable race testing
# Set to the goveralls binary path to report coverage results to Coveralls.io.
KUBE_GOVERALLS_BIN
=
${
KUBE_GOVERALLS_BIN
:-}
# Comma separated list of API Versions that should be tested.
KUBE_TEST_API_VERSIONS
=
${
KUBE_TEST_API_VERSIONS
:-
"v1beta3"
}
KUBE_TEST_API_VERSIONS
=
${
KUBE_TEST_API_VERSIONS
:-
"v1beta3
,v1
"
}
# Run tests with the standard (registry) and a custom etcd prefix
# (kubernetes.io/registry).
KUBE_TEST_ETCD_PREFIXES
=
${
KUBE_TEST_ETCD_PREFIXES
:-
"registry,kubernetes.io/registry"
}
...
...
pkg/api/v1beta3/defaults.go
View file @
d52cef11
...
...
@@ -171,6 +171,9 @@ func defaultHostNetworkPorts(containers *[]Container) {
// defaultSecurityContext performs the downward and upward merges of a pod definition
func
defaultSecurityContext
(
container
*
Container
)
{
if
container
.
SecurityContext
==
nil
{
if
(
len
(
container
.
Capabilities
.
Add
)
==
0
)
&&
(
len
(
container
.
Capabilities
.
Drop
)
==
0
)
&&
(
container
.
Privileged
==
false
)
{
return
}
glog
.
V
(
5
)
.
Infof
(
"creating security context for container %s"
,
container
.
Name
)
container
.
SecurityContext
=
&
SecurityContext
{}
}
...
...
pkg/api/validation/testdata/v1/invalidPod.yaml
0 → 100644
View file @
d52cef11
apiVersion
:
v1
kind
:
Pod
metadata
:
labels
:
name
:
redis-master
name
:
name
spec
:
containers
:
-
args
:
"
this
is
a
bad
command"
image
:
redis
name
:
master
pkg/api/validation/testdata/v1/invalidPod1.json
0 → 100644
View file @
d52cef11
{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
{
"name"
:
"name"
,
"labels"
:
{
"name"
:
"redis-master"
}
},
"spec"
:
{
"containers"
:
[
{
"name"
:
"master"
,
"image"
:
"redis"
,
"args"
:
"this is a bad command"
}
]
}
}
pkg/api/validation/testdata/v1/invalidPod2.json
0 → 100644
View file @
d52cef11
{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
{
"name"
:
"apache-php"
,
"labels"
:
{
"name"
:
"apache-php"
}
},
"spec"
:
{
"volumes"
:
[{
"name"
:
"shared-disk"
}],
"containers"
:
[
{
"name"
:
"apache-php"
,
"image"
:
"php:5.6.2-apache"
,
"ports"
:
[
{
"name"
:
"apache"
,
"hostPort"
:
"13380"
,
"containerPort"
:
80
,
"protocol"
:
"TCP"
}
],
"volumeMounts"
:
[
{
"name"
:
"shared-disk"
,
"mountPath"
:
"/var/www/html"
}
]
}
]
}
}
pkg/api/validation/testdata/v1/invalidPod3.json
0 → 100644
View file @
d52cef11
{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
{
"name"
:
"apache-php"
,
"labels"
:
{
"name"
:
"apache-php"
}
},
"spec"
:
{
"volumes"
:
[
"name"
:
"shared-disk"
],
"containers"
:
[
{
"name"
:
"apache-php"
,
"image"
:
"php:5.6.2-apache"
,
"ports"
:
[
{
"name"
:
"apache"
,
"hostPort"
:
13380
,
"containerPort"
:
80
,
"protocol"
:
"TCP"
}
],
"volumeMounts"
:
[
{
"name"
:
"shared-disk"
,
"mountPath"
:
"/var/www/html"
}
]
}
]
}
}
pkg/api/validation/testdata/v1/validPod.yaml
0 → 100644
View file @
d52cef11
apiVersion
:
v1
kind
:
Pod
metadata
:
labels
:
name
:
redis-master
name
:
name
spec
:
containers
:
-
args
:
-
this
-
is
-
an
-
ok
-
command
image
:
redis
name
:
master
pkg/kubelet/config/http_test.go
View file @
d52cef11
...
...
@@ -27,7 +27,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/securitycontext"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
)
...
...
@@ -161,7 +160,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
Image
:
"foo"
,
TerminationMessagePath
:
"/dev/termination-log"
,
ImagePullPolicy
:
"Always"
,
SecurityContext
:
securitycontext
.
ValidSecurityContextWithContainerDefaults
()
}},
}},
},
}),
},
...
...
@@ -214,7 +213,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
Image
:
"foo"
,
TerminationMessagePath
:
"/dev/termination-log"
,
ImagePullPolicy
:
"Always"
,
SecurityContext
:
securitycontext
.
ValidSecurityContextWithContainerDefaults
()
}},
}},
},
},
&
api
.
Pod
{
...
...
@@ -234,7 +233,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
Image
:
"bar"
,
TerminationMessagePath
:
"/dev/termination-log"
,
ImagePullPolicy
:
"IfNotPresent"
,
SecurityContext
:
securitycontext
.
ValidSecurityContextWithContainerDefaults
()
}},
}},
},
}),
},
...
...
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