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
635281eb
Commit
635281eb
authored
Feb 06, 2015
by
rsokolowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update guestbook example to use replication controller.
parent
e77322a5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
176 additions
and
176 deletions
+176
-176
examples_test.go
examples/examples_test.go
+6
-6
README.md
examples/guestbook/README.md
+0
-0
frontend-controller.json
examples/guestbook/frontend-controller.json
+4
-3
frontend-service.json
examples/guestbook/frontend-service.json
+4
-3
redis-master-controller.json
examples/guestbook/redis-master-controller.json
+21
-14
redis-slave-controller.json
examples/guestbook/redis-slave-controller.json
+8
-7
redis-slave-service.json
examples/guestbook/redis-slave-service.json
+2
-2
valid-pod.json
examples/limitrange/valid-pod.json
+2
-3
test-cmd.sh
hack/test-cmd.sh
+39
-38
create_test.go
pkg/kubectl/cmd/create_test.go
+15
-17
delete_test.go
pkg/kubectl/cmd/delete_test.go
+19
-21
get_test.go
pkg/kubectl/cmd/get_test.go
+20
-7
update_test.go
pkg/kubectl/cmd/update_test.go
+16
-35
builder_test.go
pkg/kubectl/resource/builder_test.go
+20
-20
No files found.
examples/examples_test.go
View file @
635281eb
...
@@ -108,12 +108,12 @@ func TestExampleObjectSchemas(t *testing.T) {
...
@@ -108,12 +108,12 @@ func TestExampleObjectSchemas(t *testing.T) {
"service-list"
:
&
api
.
ServiceList
{},
"service-list"
:
&
api
.
ServiceList
{},
},
},
"../examples/guestbook"
:
{
"../examples/guestbook"
:
{
"frontend-controller"
:
&
api
.
ReplicationController
{},
"frontend-controller"
:
&
api
.
ReplicationController
{},
"redis-slave-controller"
:
&
api
.
ReplicationController
{},
"redis-slave-controller"
:
&
api
.
ReplicationController
{},
"redis-master
"
:
&
api
.
Pod
{},
"redis-master
-controller"
:
&
api
.
ReplicationController
{},
"frontend-service"
:
&
api
.
Service
{},
"frontend-service"
:
&
api
.
Service
{},
"redis-master-service"
:
&
api
.
Service
{},
"redis-master-service"
:
&
api
.
Service
{},
"redis-slave-service"
:
&
api
.
Service
{},
"redis-slave-service"
:
&
api
.
Service
{},
},
},
"../examples/guestbook/v1beta3"
:
{
"../examples/guestbook/v1beta3"
:
{
"frontend-controller"
:
&
api
.
ReplicationController
{},
"frontend-controller"
:
&
api
.
ReplicationController
{},
...
...
examples/guestbook/README.md
View file @
635281eb
This diff is collapsed.
Click to expand it.
examples/guestbook/frontend-controller.json
View file @
635281eb
...
@@ -9,19 +9,20 @@
...
@@ -9,19 +9,20 @@
"desiredState"
:
{
"desiredState"
:
{
"manifest"
:
{
"manifest"
:
{
"version"
:
"v1beta1"
,
"version"
:
"v1beta1"
,
"id"
:
"frontend
-controller
"
,
"id"
:
"frontend"
,
"containers"
:
[{
"containers"
:
[{
"name"
:
"php-redis"
,
"name"
:
"php-redis"
,
"image"
:
"kubernetes/example-guestbook-php-redis"
,
"image"
:
"kubernetes/example-guestbook-php-redis"
,
"cpu"
:
100
,
"cpu"
:
100
,
"memory"
:
50000000
,
"memory"
:
50000000
,
"ports"
:
[{
"
containerPort"
:
80
,
"hostPort"
:
800
0
}]
"ports"
:
[{
"
name"
:
"http-server"
,
"containerPort"
:
8
0
}]
}]
}]
}
}
},
},
"labels"
:
{
"labels"
:
{
"name"
:
"frontend"
,
"name"
:
"frontend"
,
"uses"
:
"redisslave,redis-master"
"uses"
:
"redis-slave,redis-master"
,
"app"
:
"frontend"
}
}
}},
}},
"labels"
:
{
"name"
:
"frontend"
}
"labels"
:
{
"name"
:
"frontend"
}
...
...
examples/guestbook/frontend-service.json
View file @
635281eb
...
@@ -2,12 +2,13 @@
...
@@ -2,12 +2,13 @@
"id"
:
"frontend"
,
"id"
:
"frontend"
,
"kind"
:
"Service"
,
"kind"
:
"Service"
,
"apiVersion"
:
"v1beta1"
,
"apiVersion"
:
"v1beta1"
,
"port"
:
80
,
"port"
:
80
00
,
"containerPort"
:
80
,
"containerPort"
:
"http-server"
,
"selector"
:
{
"selector"
:
{
"name"
:
"frontend"
"name"
:
"frontend"
},
},
"labels"
:
{
"labels"
:
{
"name"
:
"frontend"
"name"
:
"frontend"
}
},
"createExternalLoadBalancer"
:
true
}
}
examples/guestbook/redis-master.json
→
examples/guestbook/redis-master
-controller
.json
View file @
635281eb
{
{
"id"
:
"redis-master"
,
"id"
:
"redis-master
-controller
"
,
"kind"
:
"
Pod
"
,
"kind"
:
"
ReplicationController
"
,
"apiVersion"
:
"v1beta1"
,
"apiVersion"
:
"v1beta1"
,
"desiredState"
:
{
"desiredState"
:
{
"manifest"
:
{
"replicas"
:
1
,
"version"
:
"v1beta1"
,
"replicaSelector"
:
{
"name"
:
"redis-master"
},
"id"
:
"redis-master"
,
"podTemplate"
:
{
"containers"
:
[{
"desiredState"
:
{
"name"
:
"master"
,
"manifest"
:
{
"image"
:
"dockerfile/redis"
,
"version"
:
"v1beta1"
,
"cpu"
:
100
,
"id"
:
"redis-master"
,
"ports"
:
[{
"containers"
:
[{
"containerPort"
:
6379
,
"name"
:
"redis-master"
,
"hostPort"
:
6379
"image"
:
"dockerfile/redis"
,
}]
"cpu"
:
100
,
}]
"ports"
:
[{
"containerPort"
:
6379
}]
}]
}
},
"labels"
:
{
"name"
:
"redis-master"
,
"app"
:
"redis"
}
}
}
},
},
"labels"
:
{
"labels"
:
{
...
...
examples/guestbook/redis-slave-controller.json
View file @
635281eb
...
@@ -4,25 +4,26 @@
...
@@ -4,25 +4,26 @@
"apiVersion"
:
"v1beta1"
,
"apiVersion"
:
"v1beta1"
,
"desiredState"
:
{
"desiredState"
:
{
"replicas"
:
2
,
"replicas"
:
2
,
"replicaSelector"
:
{
"name"
:
"redisslave"
},
"replicaSelector"
:
{
"name"
:
"redis
-
slave"
},
"podTemplate"
:
{
"podTemplate"
:
{
"desiredState"
:
{
"desiredState"
:
{
"manifest"
:
{
"manifest"
:
{
"version"
:
"v1beta1"
,
"version"
:
"v1beta1"
,
"id"
:
"redis-slave
-controller
"
,
"id"
:
"redis-slave"
,
"containers"
:
[{
"containers"
:
[{
"name"
:
"slave"
,
"name"
:
"
redis-
slave"
,
"image"
:
"brendanburns/redis-slave"
,
"image"
:
"brendanburns/redis-slave"
,
"cpu"
:
200
,
"cpu"
:
200
,
"ports"
:
[{
"containerPort"
:
6379
,
"hostPort"
:
6380
}]
"ports"
:
[{
"containerPort"
:
6379
}]
}]
}]
}
}
},
},
"labels"
:
{
"labels"
:
{
"name"
:
"redisslave"
,
"name"
:
"redis-slave"
,
"uses"
:
"redis-master"
"uses"
:
"redis-master"
,
"app"
:
"redis"
}
}
}
}
},
},
"labels"
:
{
"name"
:
"redisslave"
}
"labels"
:
{
"name"
:
"redis
-
slave"
}
}
}
examples/guestbook/redis-slave-service.json
View file @
635281eb
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
"port"
:
6379
,
"port"
:
6379
,
"containerPort"
:
6379
,
"containerPort"
:
6379
,
"labels"
:
{
"labels"
:
{
"name"
:
"redisslave"
"name"
:
"redis
-
slave"
},
},
"selector"
:
{
"selector"
:
{
"name"
:
"redisslave"
"name"
:
"redis
-
slave"
}
}
}
}
examples/limitrange/valid-pod.json
View file @
635281eb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
"desiredState"
:
{
"desiredState"
:
{
"manifest"
:
{
"manifest"
:
{
"version"
:
"v1beta1"
,
"version"
:
"v1beta1"
,
"id"
:
"
in
valid-pod"
,
"id"
:
"valid-pod"
,
"containers"
:
[{
"containers"
:
[{
"name"
:
"kubernetes-serve-hostname"
,
"name"
:
"kubernetes-serve-hostname"
,
"image"
:
"kubernetes/serve_hostname"
,
"image"
:
"kubernetes/serve_hostname"
,
...
@@ -17,4 +17,4 @@
...
@@ -17,4 +17,4 @@
}]
}]
}
}
},
},
}
}
\ No newline at end of file
hack/test-cmd.sh
View file @
635281eb
...
@@ -132,67 +132,68 @@ for version in "${kube_api_versions[@]}"; do
...
@@ -132,67 +132,68 @@ for version in "${kube_api_versions[@]}"; do
kube::log::status
"Testing kubectl(
${
version
}
:pods)"
kube::log::status
"Testing kubectl(
${
version
}
:pods)"
kubectl get pods
"
${
kube_flags
[@]
}
"
kubectl get pods
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/
guestbook/redis-master
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/
limitrange/valid-pod
.json
"
${
kube_flags
[@]
}
"
kubectl get pods
"
${
kube_flags
[@]
}
"
kubectl get pods
"
${
kube_flags
[@]
}
"
kubectl get pod
redis-master
"
${
kube_flags
[@]
}
"
kubectl get pod
valid-pod
"
${
kube_flags
[@]
}
"
[
"
$(
kubectl get pod
redis-master
-o
template
--output-version
=
v1beta1
-t
'{{ .id }}'
"
${
kube_flags
[@]
}
"
)
"
==
"redis-master
"
]
[
"
$(
kubectl get pod
valid-pod
-o
template
--output-version
=
v1beta1
-t
'{{ .id }}'
"
${
kube_flags
[@]
}
"
)
"
==
"valid-pod
"
]
output_pod
=
$(
kubectl get pod
redis-master
-o
yaml
--output-version
=
v1beta1
"
${
kube_flags
[@]
}
"
)
output_pod
=
$(
kubectl get pod
valid-pod
-o
yaml
--output-version
=
v1beta1
"
${
kube_flags
[@]
}
"
)
kubectl delete pod
redis-master
"
${
kube_flags
[@]
}
"
kubectl delete pod
valid-pod
"
${
kube_flags
[@]
}
"
before
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
before
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
echo
"
${
output_pod
}
"
| kubectl create
-f
-
"
${
kube_flags
[@]
}
"
echo
"
${
output_pod
}
"
| kubectl create
-f
-
"
${
kube_flags
[@]
}
"
after
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
after
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$((${
after
}
-
${
before
}))
"
-eq
1
]
[
"
$((${
after
}
-
${
before
}))
"
-eq
1
]
kubectl get pods
-o
yaml
--output-version
=
v1beta1
"
${
kube_flags
[@]
}
"
|
grep
-q
"id: redis-master"
kubectl get pods
-o
yaml
--output-version
=
v1beta1
"
${
kube_flags
[@]
}
"
|
grep
-q
"id: valid-pod"
kubectl describe pod redis-master
"
${
kube_flags
[@]
}
"
|
grep
-q
'Name:.*redis-master'
kubectl describe pod valid-pod
"
${
kube_flags
[@]
}
"
|
grep
-q
'Name:.*valid-pod'
kubectl delete
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
kubectl delete
-f
examples/limitrange/valid-pod.json
"
${
kube_flags
[@]
}
"
kubectl delete pods
-l
name
=
redis-master
"
${
kube_flags
[@]
}
"
[
!
$(
kubectl get pods
"
${
kube_flags
[@]
}
"
-lname
=
redis-master |
grep
-q
'redis-master'
)
]
kubectl delete pods
-l
name
=
valid-pod
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
[
!
$(
kubectl get pods
"
${
kube_flags
[@]
}
"
-lname
=
valid-pod |
grep
-q
'valid-pod'
)
]
kubectl get pods
"
${
kube_flags
[@]
}
"
-lname
=
redis-master |
grep
-q
'redis-master'
kubectl create
-f
examples/limitrange/valid-pod.json
"
${
kube_flags
[@]
}
"
kubectl get pods
"
${
kube_flags
[@]
}
"
-lname
=
valid-pod |
grep
-q
'valid-pod'
[
!
$(
kubectl delete pods
"
${
kube_flags
[@]
}
"
)
]
[
!
$(
kubectl delete pods
"
${
kube_flags
[@]
}
"
)
]
kubectl get pods
"
${
kube_flags
[@]
}
"
-lname
=
redis-master |
grep
-q
'redis-master
'
kubectl get pods
"
${
kube_flags
[@]
}
"
-lname
=
valid-pod |
grep
-q
'valid-pod
'
[
!
$(
kubectl delete pods
--all
pods
-l
name
=
redis-master
"
${
kube_flags
[@]
}
"
)
]
# not --all and label selector together
[
!
$(
kubectl delete pods
--all
pods
-l
name
=
valid-pod
"
${
kube_flags
[@]
}
"
)
]
# not --all and label selector together
kubectl delete
--all
pods
"
${
kube_flags
[@]
}
"
# --all remove all the pods
kubectl delete
--all
pods
"
${
kube_flags
[@]
}
"
# --all remove all the pods
kubectl create
-f
examples/
guestbook/redis-master
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/
limitrange/valid-pod
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/redis/redis-proxy.yaml
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/redis/redis-proxy.yaml
"
${
kube_flags
[@]
}
"
kubectl get pods
redis-master
redis-proxy
"
${
kube_flags
[@]
}
"
kubectl get pods
valid-pod
redis-proxy
"
${
kube_flags
[@]
}
"
kubectl delete pods
redis-master redis-proxy
# delete multiple pods at once
kubectl delete pods
valid-pod redis-proxy
"
${
kube_flags
[@]
}
"
# delete multiple pods at once
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$howmanypods
"
-eq
0
]
[
"
$howmanypods
"
-eq
0
]
kubectl create
-f
examples/
guestbook/redis-master
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/
limitrange/valid-pod
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/redis/redis-proxy.yaml
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/redis/redis-proxy.yaml
"
${
kube_flags
[@]
}
"
kubectl stop pods
redis-master redis-proxy
# stop multiple pods at once
kubectl stop pods
valid-pod redis-proxy
"
${
kube_flags
[@]
}
"
# stop multiple pods at once
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$howmanypods
"
-eq
0
]
[
"
$howmanypods
"
-eq
0
]
kubectl create
-f
examples/
guestbook/redis-master
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/
limitrange/valid-pod
.json
"
${
kube_flags
[@]
}
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$howmanypods
"
-eq
1
]
[
"
$howmanypods
"
-eq
1
]
#testing pods and label command command
#testing pods and label command command
kubectl label pods
redis-master new-name
=
new-redis-master
"
${
kube_flags
[@]
}
"
kubectl label pods
valid-pod new-name
=
new-valid-pod
"
${
kube_flags
[@]
}
"
kubectl delete pods
-lnew-name
=
new-
redis-master
"
${
kube_flags
[@]
}
"
kubectl delete pods
-lnew-name
=
new-
valid-pod
"
${
kube_flags
[@]
}
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$howmanypods
"
-eq
0
]
[
"
$howmanypods
"
-eq
0
]
kubectl create
-f
examples/
guestbook/redis-master
.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/
limitrange/valid-pod
.json
"
${
kube_flags
[@]
}
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
howmanypods
=
"
$(
kubectl get pods
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$howmanypods
"
-eq
1
]
[
"
$howmanypods
"
-eq
1
]
!
$(
kubectl label pods
redis-master
name
=
redis
-super-sayan
"
${
kube_flags
[@]
}
"
)
!
$(
kubectl label pods
valid-pod
name
=
valid-pod
-super-sayan
"
${
kube_flags
[@]
}
"
)
kubectl label
--overwrite
pods
redis-master
name
=
redis
-super-sayan
"
${
kube_flags
[@]
}
"
kubectl label
--overwrite
pods
valid-pod
name
=
valid-pod
-super-sayan
"
${
kube_flags
[@]
}
"
kubectl delete pods
-lname
=
redis
-super-sayan
"
${
kube_flags
[@]
}
"
kubectl delete pods
-lname
=
valid-pod
-super-sayan
"
${
kube_flags
[@]
}
"
howmanypods
=
"
$(
kubectl get pods
-lname
=
redis
-super-sayan
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
howmanypods
=
"
$(
kubectl get pods
-lname
=
valid-pod
-super-sayan
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$howmanypods
"
-eq
0
]
[
"
$howmanypods
"
-eq
0
]
# make calls in another namespace
# make calls in another namespace
kubectl create
--namespace
=
other
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
kubectl create
"
${
kube_flags
[@]
}
"
--namespace
=
other
-f
examples/limitrange/valid-pod.json
kubectl get
pod
--namespace
=
other redis-master
kubectl get
"
${
kube_flags
[@]
}
"
pod
--namespace
=
other valid-pod
kubectl delete
pod
--namespace
=
other redis-master
kubectl delete
"
${
kube_flags
[@]
}
"
pod
--namespace
=
other valid-pod
kube::log::status
"Testing kubectl(
${
version
}
:services)"
kube::log::status
"Testing kubectl(
${
version
}
:services)"
kubectl get services
"
${
kube_flags
[@]
}
"
kubectl get services
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/
frontend
-service.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/
redis-master
-service.json
"
${
kube_flags
[@]
}
"
kubectl get services
"
${
kube_flags
[@]
}
"
kubectl get services
"
${
kube_flags
[@]
}
"
output_service
=
$(
kubectl get service
frontend
-o
json
--output-version
=
v1beta3
"
${
kube_flags
[@]
}
"
)
output_service
=
$(
kubectl get service
redis-master
-o
json
--output-version
=
v1beta3
"
${
kube_flags
[@]
}
"
)
kubectl delete service
frontend
"
${
kube_flags
[@]
}
"
kubectl delete service
redis-master
"
${
kube_flags
[@]
}
"
echo
"
${
output_service
}
"
| kubectl create
-f
-
"
${
kube_flags
[@]
}
"
echo
"
${
output_service
}
"
| kubectl create
-f
-
"
${
kube_flags
[@]
}
"
kubectl create
-f
-
"
${
kube_flags
[@]
}
"
<<
__EOF__
kubectl create
-f
-
"
${
kube_flags
[@]
}
"
<<
__EOF__
{
{
...
@@ -206,15 +207,15 @@ for version in "${kube_api_versions[@]}"; do
...
@@ -206,15 +207,15 @@ for version in "${kube_api_versions[@]}"; do
}
}
}
}
__EOF__
__EOF__
kubectl update service service-
${
version
}
-test
--patch
=
"{
\"
selector
\"
:{
\"
version
\"
:
\"
${
version
}
\"
},
\"
apiVersion
\"
:
\"
${
version
}
\"
}"
kubectl update service
"
${
kube_flags
[@]
}
"
service-
${
version
}
-test
--patch
=
"{
\"
selector
\"
:{
\"
version
\"
:
\"
${
version
}
\"
},
\"
apiVersion
\"
:
\"
${
version
}
\"
}"
kubectl get service
service-
${
version
}
-test
-o
json | kubectl update
-f
-
kubectl get service
"
${
kube_flags
[@]
}
"
service-
${
version
}
-test
-o
json | kubectl update
"
${
kube_flags
[@]
}
"
-f
-
kubectl get services
"
${
kube_flags
[@]
}
"
kubectl get services
"
${
kube_flags
[@]
}
"
kubectl get services
"service-
${
version
}
-test"
"
${
kube_flags
[@]
}
"
kubectl get services
"service-
${
version
}
-test"
"
${
kube_flags
[@]
}
"
kubectl delete service
frontend
"
${
kube_flags
[@]
}
"
kubectl delete service
redis-master
"
${
kube_flags
[@]
}
"
servicesbefore
=
"
$(
kubectl get services
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
servicesbefore
=
"
$(
kubectl get services
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
kubectl create
-f
examples/guestbook/
frontend
-service.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/
redis-master
-service.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-slave-service.json
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-slave-service.json
"
${
kube_flags
[@]
}
"
kubectl delete services
frontend redisslave
# delete multiple services at once
kubectl delete services
redis-master redisslave
"
${
kube_flags
[@]
}
"
# delete multiple services at once
servicesafter
=
"
$(
kubectl get services
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
servicesafter
=
"
$(
kubectl get services
-o
template
-t
"{{ len .items }}"
"
${
kube_flags
[@]
}
"
)
"
[
"
$((${
servicesafter
}
-
${
servicesbefore
}))
"
-eq
0
]
[
"
$((${
servicesafter
}
-
${
servicesbefore
}))
"
-eq
0
]
...
...
pkg/kubectl/cmd/create_test.go
View file @
635281eb
...
@@ -25,8 +25,8 @@ import (
...
@@ -25,8 +25,8 @@ import (
)
)
func
TestCreateObject
(
t
*
testing
.
T
)
{
func
TestCreateObject
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
_
,
_
,
rc
:=
testData
()
pods
.
Items
[
0
]
.
Name
=
"redis-mast
er"
rc
.
Items
[
0
]
.
Name
=
"redis-master-controll
er"
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -34,8 +34,8 @@ func TestCreateObject(t *testing.T) {
...
@@ -34,8 +34,8 @@ func TestCreateObject(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/
pod
s"
&&
m
==
"POST"
:
case
p
==
"/namespaces/test/
replicationcontroller
s"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
return
nil
,
nil
return
nil
,
nil
...
@@ -46,17 +46,17 @@ func TestCreateObject(t *testing.T) {
...
@@ -46,17 +46,17 @@ func TestCreateObject(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdCreate
(
buf
)
cmd
:=
f
.
NewCmdCreate
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
// uses the name from the file, not the response
// uses the name from the file, not the response
if
buf
.
String
()
!=
"redis-master
\n
"
{
if
buf
.
String
()
!=
"redis-master
-controller
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
func
TestCreateMultipleObject
(
t
*
testing
.
T
)
{
func
TestCreateMultipleObject
(
t
*
testing
.
T
)
{
pods
,
sv
c
:=
testData
()
_
,
svc
,
r
c
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -64,10 +64,10 @@ func TestCreateMultipleObject(t *testing.T) {
...
@@ -64,10 +64,10 @@ func TestCreateMultipleObject(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/pods"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/services"
&&
m
==
"POST"
:
case
p
==
"/namespaces/test/services"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/replicationcontrollers"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
return
nil
,
nil
return
nil
,
nil
...
@@ -78,19 +78,19 @@ func TestCreateMultipleObject(t *testing.T) {
...
@@ -78,19 +78,19 @@ func TestCreateMultipleObject(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdCreate
(
buf
)
cmd
:=
f
.
NewCmdCreate
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
// Names should come from the REST response, NOT the files
// Names should come from the REST response, NOT the files
if
buf
.
String
()
!=
"
foo
\n
baz
\n
"
{
if
buf
.
String
()
!=
"
rc1
\n
baz
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
func
TestCreateDirectory
(
t
*
testing
.
T
)
{
func
TestCreateDirectory
(
t
*
testing
.
T
)
{
pods
,
sv
c
:=
testData
()
_
,
svc
,
r
c
:=
testData
()
pods
.
Items
[
0
]
.
Name
=
"redis-master
"
rc
.
Items
[
0
]
.
Name
=
"name
"
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -98,12 +98,10 @@ func TestCreateDirectory(t *testing.T) {
...
@@ -98,12 +98,10 @@ func TestCreateDirectory(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/pods"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/services"
&&
m
==
"POST"
:
case
p
==
"/namespaces/test/services"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/replicationcontrollers"
&&
m
==
"POST"
:
case
p
==
"/namespaces/test/replicationcontrollers"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
sv
c
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
r
c
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
return
nil
,
nil
return
nil
,
nil
...
@@ -117,7 +115,7 @@ func TestCreateDirectory(t *testing.T) {
...
@@ -117,7 +115,7 @@ func TestCreateDirectory(t *testing.T) {
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
if
buf
.
String
()
!=
"
baz
\n
baz
\n
baz
\n
redis-master
\n
baz
\n
baz
\n
"
{
if
buf
.
String
()
!=
"
name
\n
baz
\n
name
\n
baz
\n
name
\n
baz
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
pkg/kubectl/cmd/delete_test.go
View file @
635281eb
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
)
)
func
TestDeleteObject
(
t
*
testing
.
T
)
{
func
TestDeleteObject
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
_
,
_
,
rc
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -34,8 +34,8 @@ func TestDeleteObject(t *testing.T) {
...
@@ -34,8 +34,8 @@ func TestDeleteObject(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/
pods/redis-mast
er"
&&
m
==
"DELETE"
:
case
p
==
"/namespaces/test/
replicationcontrollers/redis-master-controll
er"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
return
nil
,
nil
return
nil
,
nil
...
@@ -46,11 +46,11 @@ func TestDeleteObject(t *testing.T) {
...
@@ -46,11 +46,11 @@ func TestDeleteObject(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
// uses the name from the file, not the response
// uses the name from the file, not the response
if
buf
.
String
()
!=
"redis-master
\n
"
{
if
buf
.
String
()
!=
"redis-master
-controller
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
...
@@ -62,7 +62,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
...
@@ -62,7 +62,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/
pods/redis-mast
er"
&&
m
==
"DELETE"
:
case
p
==
"/namespaces/test/
replicationcontrollers/redis-master-controll
er"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
...
@@ -74,7 +74,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
...
@@ -74,7 +74,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
if
buf
.
String
()
!=
""
{
if
buf
.
String
()
!=
""
{
...
@@ -83,7 +83,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
...
@@ -83,7 +83,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
}
}
func
TestDeleteMultipleObject
(
t
*
testing
.
T
)
{
func
TestDeleteMultipleObject
(
t
*
testing
.
T
)
{
pods
,
sv
c
:=
testData
()
_
,
svc
,
r
c
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -91,8 +91,8 @@ func TestDeleteMultipleObject(t *testing.T) {
...
@@ -91,8 +91,8 @@ func TestDeleteMultipleObject(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/
pods/redis-mast
er"
&&
m
==
"DELETE"
:
case
p
==
"/namespaces/test/
replicationcontrollers/redis-master-controll
er"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"DELETE"
:
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
default
:
default
:
...
@@ -105,17 +105,17 @@ func TestDeleteMultipleObject(t *testing.T) {
...
@@ -105,17 +105,17 @@ func TestDeleteMultipleObject(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
if
buf
.
String
()
!=
"redis-master
\n
frontend
\n
"
{
if
buf
.
String
()
!=
"redis-master
-controller
\n
frontend
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
func
TestDeleteMultipleObjectIgnoreMissing
(
t
*
testing
.
T
)
{
func
TestDeleteMultipleObjectIgnoreMissing
(
t
*
testing
.
T
)
{
_
,
svc
:=
testData
()
_
,
svc
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -123,7 +123,7 @@ func TestDeleteMultipleObjectIgnoreMissing(t *testing.T) {
...
@@ -123,7 +123,7 @@ func TestDeleteMultipleObjectIgnoreMissing(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/
pods/redis-mast
er"
&&
m
==
"DELETE"
:
case
p
==
"/namespaces/test/
replicationcontrollers/redis-master-controll
er"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"DELETE"
:
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
@@ -137,7 +137,7 @@ func TestDeleteMultipleObjectIgnoreMissing(t *testing.T) {
...
@@ -137,7 +137,7 @@ func TestDeleteMultipleObjectIgnoreMissing(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
:=
f
.
NewCmdDelete
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
...
@@ -147,7 +147,7 @@ func TestDeleteMultipleObjectIgnoreMissing(t *testing.T) {
...
@@ -147,7 +147,7 @@ func TestDeleteMultipleObjectIgnoreMissing(t *testing.T) {
}
}
func
TestDeleteDirectory
(
t
*
testing
.
T
)
{
func
TestDeleteDirectory
(
t
*
testing
.
T
)
{
pods
,
sv
c
:=
testData
()
_
,
svc
,
r
c
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -155,12 +155,10 @@ func TestDeleteDirectory(t *testing.T) {
...
@@ -155,12 +155,10 @@ func TestDeleteDirectory(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/pods/"
)
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/services/"
)
&&
m
==
"DELETE"
:
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/services/"
)
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/replicationcontrollers/"
)
&&
m
==
"DELETE"
:
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/replicationcontrollers/"
)
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
sv
c
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
r
c
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
return
nil
,
nil
return
nil
,
nil
...
@@ -174,13 +172,13 @@ func TestDeleteDirectory(t *testing.T) {
...
@@ -174,13 +172,13 @@ func TestDeleteDirectory(t *testing.T) {
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
if
buf
.
String
()
!=
"frontend-controller
\n
frontend
\n
redis-master
\n
redis-master
\n
redis-slave-controller
\n
redisslave
\n
"
{
if
buf
.
String
()
!=
"frontend-controller
\n
frontend
\n
redis-master
-controller
\n
redis-master
\n
redis-slave-controller
\n
redisslave
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
func
TestDeleteMultipleSelector
(
t
*
testing
.
T
)
{
func
TestDeleteMultipleSelector
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
pods
,
svc
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
...
pkg/kubectl/cmd/get_test.go
View file @
635281eb
...
@@ -34,7 +34,7 @@ import (
...
@@ -34,7 +34,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch/json"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch/json"
)
)
func
testData
()
(
*
api
.
PodList
,
*
api
.
ServiceList
)
{
func
testData
()
(
*
api
.
PodList
,
*
api
.
ServiceList
,
*
api
.
ReplicationControllerList
)
{
pods
:=
&
api
.
PodList
{
pods
:=
&
api
.
PodList
{
ListMeta
:
api
.
ListMeta
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"15"
,
ResourceVersion
:
"15"
,
...
@@ -70,7 +70,20 @@ func testData() (*api.PodList, *api.ServiceList) {
...
@@ -70,7 +70,20 @@ func testData() (*api.PodList, *api.ServiceList) {
},
},
},
},
}
}
return
pods
,
svc
rc
:=
&
api
.
ReplicationControllerList
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"17"
,
},
Items
:
[]
api
.
ReplicationController
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"rc1"
,
Namespace
:
"test"
,
ResourceVersion
:
"18"
},
Spec
:
api
.
ReplicationControllerSpec
{
Replicas
:
1
,
},
},
},
}
return
pods
,
svc
,
rc
}
}
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
...
@@ -123,7 +136,7 @@ func TestGetSchemaObject(t *testing.T) {
...
@@ -123,7 +136,7 @@ func TestGetSchemaObject(t *testing.T) {
}
}
func
TestGetObjects
(
t
*
testing
.
T
)
{
func
TestGetObjects
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -149,7 +162,7 @@ func TestGetObjects(t *testing.T) {
...
@@ -149,7 +162,7 @@ func TestGetObjects(t *testing.T) {
}
}
func
TestGetListObjects
(
t
*
testing
.
T
)
{
func
TestGetListObjects
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -175,7 +188,7 @@ func TestGetListObjects(t *testing.T) {
...
@@ -175,7 +188,7 @@ func TestGetListObjects(t *testing.T) {
}
}
func
TestGetMultipleTypeObjects
(
t
*
testing
.
T
)
{
func
TestGetMultipleTypeObjects
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
pods
,
svc
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -211,7 +224,7 @@ func TestGetMultipleTypeObjects(t *testing.T) {
...
@@ -211,7 +224,7 @@ func TestGetMultipleTypeObjects(t *testing.T) {
}
}
func
TestGetMultipleTypeObjectsAsList
(
t
*
testing
.
T
)
{
func
TestGetMultipleTypeObjectsAsList
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
pods
,
svc
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -260,7 +273,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
...
@@ -260,7 +273,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
}
}
func
TestGetMultipleTypeObjectsWithSelector
(
t
*
testing
.
T
)
{
func
TestGetMultipleTypeObjectsWithSelector
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
pods
,
svc
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
...
pkg/kubectl/cmd/update_test.go
View file @
635281eb
...
@@ -22,26 +22,11 @@ import (
...
@@ -22,26 +22,11 @@ import (
"strings"
"strings"
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
)
)
func
rcTestData
()
*
api
.
ReplicationControllerList
{
rc
:=
&
api
.
ReplicationControllerList
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"17"
,
},
Items
:
[]
api
.
ReplicationController
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"qux"
,
Namespace
:
"test"
,
ResourceVersion
:
"13"
},
},
},
}
return
rc
}
func
TestUpdateObject
(
t
*
testing
.
T
)
{
func
TestUpdateObject
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
_
,
_
,
rc
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -49,10 +34,10 @@ func TestUpdateObject(t *testing.T) {
...
@@ -49,10 +34,10 @@ func TestUpdateObject(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/
pods/redis-mast
er"
&&
m
==
"GET"
:
case
p
==
"/namespaces/test/
replicationcontrollers/redis-master-controll
er"
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/
pods/redis-mast
er"
&&
m
==
"PUT"
:
case
p
==
"/namespaces/test/
replicationcontrollers/redis-master-controll
er"
&&
m
==
"PUT"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
return
nil
,
nil
return
nil
,
nil
...
@@ -63,17 +48,17 @@ func TestUpdateObject(t *testing.T) {
...
@@ -63,17 +48,17 @@ func TestUpdateObject(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdUpdate
(
buf
)
cmd
:=
f
.
NewCmdUpdate
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
// uses the name from the file, not the response
// uses the name from the file, not the response
if
buf
.
String
()
!=
"
foo
\n
"
{
if
buf
.
String
()
!=
"
rc1
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
func
TestUpdateMultipleObject
(
t
*
testing
.
T
)
{
func
TestUpdateMultipleObject
(
t
*
testing
.
T
)
{
pods
,
sv
c
:=
testData
()
_
,
svc
,
r
c
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -81,11 +66,10 @@ func TestUpdateMultipleObject(t *testing.T) {
...
@@ -81,11 +66,10 @@ func TestUpdateMultipleObject(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/pods/redis-master"
&&
m
==
"GET"
:
case
p
==
"/namespaces/test/replicationcontrollers/redis-master-controller"
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/pods/redis-master"
&&
m
==
"PUT"
:
case
p
==
"/namespaces/test/replicationcontrollers/redis-master-controller"
&&
m
==
"PUT"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"GET"
:
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"PUT"
:
case
p
==
"/namespaces/test/services/frontend"
&&
m
==
"PUT"
:
...
@@ -100,18 +84,17 @@ func TestUpdateMultipleObject(t *testing.T) {
...
@@ -100,18 +84,17 @@ func TestUpdateMultipleObject(t *testing.T) {
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdUpdate
(
buf
)
cmd
:=
f
.
NewCmdUpdate
(
buf
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/redis-master
-controller
.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Flags
()
.
Set
(
"filename"
,
"../../../examples/guestbook/frontend-service.json"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
if
buf
.
String
()
!=
"
foo
\n
baz
\n
"
{
if
buf
.
String
()
!=
"
rc1
\n
baz
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
func
TestUpdateDirectory
(
t
*
testing
.
T
)
{
func
TestUpdateDirectory
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
_
,
svc
,
rc
:=
testData
()
rc
:=
rcTestData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
...
@@ -119,8 +102,6 @@ func TestUpdateDirectory(t *testing.T) {
...
@@ -119,8 +102,6 @@ func TestUpdateDirectory(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
client
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/pods/"
)
&&
(
m
==
"GET"
||
m
==
"PUT"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/services/"
)
&&
(
m
==
"GET"
||
m
==
"PUT"
)
:
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/services/"
)
&&
(
m
==
"GET"
||
m
==
"PUT"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/replicationcontrollers/"
)
&&
(
m
==
"GET"
||
m
==
"PUT"
)
:
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/replicationcontrollers/"
)
&&
(
m
==
"GET"
||
m
==
"PUT"
)
:
...
@@ -139,7 +120,7 @@ func TestUpdateDirectory(t *testing.T) {
...
@@ -139,7 +120,7 @@ func TestUpdateDirectory(t *testing.T) {
cmd
.
Flags
()
.
Set
(
"namespace"
,
"test"
)
cmd
.
Flags
()
.
Set
(
"namespace"
,
"test"
)
cmd
.
Run
(
cmd
,
[]
string
{})
cmd
.
Run
(
cmd
,
[]
string
{})
if
buf
.
String
()
!=
"
qux
\n
baz
\n
baz
\n
foo
\n
qux
\n
baz
\n
"
{
if
buf
.
String
()
!=
"
rc1
\n
baz
\n
rc1
\n
baz
\n
rc1
\n
baz
\n
"
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
pkg/kubectl/resource/builder_test.go
View file @
635281eb
...
@@ -166,7 +166,7 @@ func (v *testVisitor) Objects() []runtime.Object {
...
@@ -166,7 +166,7 @@ func (v *testVisitor) Objects() []runtime.Object {
func
TestPathBuilder
(
t
*
testing
.
T
)
{
func
TestPathBuilder
(
t
*
testing
.
T
)
{
b
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
b
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
FilenameParam
(
"../../../examples/guestbook/redis-master
-controller
.json"
)
test
:=
&
testVisitor
{}
test
:=
&
testVisitor
{}
singular
:=
false
singular
:=
false
...
@@ -177,7 +177,7 @@ func TestPathBuilder(t *testing.T) {
...
@@ -177,7 +177,7 @@ func TestPathBuilder(t *testing.T) {
}
}
info
:=
test
.
Infos
[
0
]
info
:=
test
.
Infos
[
0
]
if
info
.
Name
!=
"redis-master"
||
info
.
Namespace
!=
""
||
info
.
Object
==
nil
{
if
info
.
Name
!=
"redis-master
-controller
"
||
info
.
Namespace
!=
""
||
info
.
Object
==
nil
{
t
.
Errorf
(
"unexpected info: %#v"
,
info
)
t
.
Errorf
(
"unexpected info: %#v"
,
info
)
}
}
}
}
...
@@ -215,8 +215,8 @@ func TestNodeBuilder(t *testing.T) {
...
@@ -215,8 +215,8 @@ func TestNodeBuilder(t *testing.T) {
func
TestPathBuilderWithMultiple
(
t
*
testing
.
T
)
{
func
TestPathBuilderWithMultiple
(
t
*
testing
.
T
)
{
b
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
b
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
.
FilenameParam
(
"../../../examples/guestbook/redis-master
-controller
.json"
)
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
.
FilenameParam
(
"../../../examples/guestbook/redis-master
-controller
.json"
)
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
test
:=
&
testVisitor
{}
test
:=
&
testVisitor
{}
...
@@ -228,7 +228,7 @@ func TestPathBuilderWithMultiple(t *testing.T) {
...
@@ -228,7 +228,7 @@ func TestPathBuilderWithMultiple(t *testing.T) {
}
}
info
:=
test
.
Infos
[
1
]
info
:=
test
.
Infos
[
1
]
if
info
.
Name
!=
"redis-master"
||
info
.
Namespace
!=
"test"
||
info
.
Object
==
nil
{
if
info
.
Name
!=
"redis-master
-controller
"
||
info
.
Namespace
!=
"test"
||
info
.
Object
==
nil
{
t
.
Errorf
(
"unexpected info: %#v"
,
info
)
t
.
Errorf
(
"unexpected info: %#v"
,
info
)
}
}
}
}
...
@@ -248,7 +248,7 @@ func TestDirectoryBuilder(t *testing.T) {
...
@@ -248,7 +248,7 @@ func TestDirectoryBuilder(t *testing.T) {
found
:=
false
found
:=
false
for
_
,
info
:=
range
test
.
Infos
{
for
_
,
info
:=
range
test
.
Infos
{
if
info
.
Name
==
"redis-master"
&&
info
.
Namespace
==
"test"
&&
info
.
Object
!=
nil
{
if
info
.
Name
==
"redis-master
-controller
"
&&
info
.
Namespace
==
"test"
&&
info
.
Object
!=
nil
{
found
=
true
found
=
true
}
}
}
}
...
@@ -474,7 +474,7 @@ func TestMultipleObject(t *testing.T) {
...
@@ -474,7 +474,7 @@ func TestMultipleObject(t *testing.T) {
func
TestSingularObject
(
t
*
testing
.
T
)
{
func
TestSingularObject
(
t
*
testing
.
T
)
{
obj
,
err
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
obj
,
err
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
.
FilenameParam
(
"../../../examples/guestbook/redis-master
-controller
.json"
)
.
Flatten
()
.
Flatten
()
.
Do
()
.
Object
()
Do
()
.
Object
()
...
@@ -482,12 +482,12 @@ func TestSingularObject(t *testing.T) {
...
@@ -482,12 +482,12 @@ func TestSingularObject(t *testing.T) {
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
pod
,
ok
:=
obj
.
(
*
api
.
Pod
)
rc
,
ok
:=
obj
.
(
*
api
.
ReplicationController
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"unexpected object: %#v"
,
obj
)
t
.
Fatalf
(
"unexpected object: %#v"
,
obj
)
}
}
if
pod
.
Name
!=
"redis-master"
||
pod
.
Namespace
!=
"test"
{
if
rc
.
Name
!=
"redis-master-controller"
||
rc
.
Namespace
!=
"test"
{
t
.
Errorf
(
"unexpected
pod: %#v"
,
pod
)
t
.
Errorf
(
"unexpected
controller: %#v"
,
rc
)
}
}
}
}
...
@@ -550,16 +550,16 @@ func TestListObjectWithDifferentVersions(t *testing.T) {
...
@@ -550,16 +550,16 @@ func TestListObjectWithDifferentVersions(t *testing.T) {
}
}
func
TestWatch
(
t
*
testing
.
T
)
{
func
TestWatch
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
_
,
svc
:=
testData
()
w
,
err
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClientWith
(
t
,
map
[
string
]
string
{
w
,
err
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClientWith
(
t
,
map
[
string
]
string
{
"/watch/namespaces/test/
pods/redis-master?resourceVersion=10
"
:
watchBody
(
watch
.
Event
{
"/watch/namespaces/test/
services/redis-master?resourceVersion=12
"
:
watchBody
(
watch
.
Event
{
Type
:
watch
.
Added
,
Type
:
watch
.
Added
,
Object
:
&
pods
.
Items
[
0
],
Object
:
&
svc
.
Items
[
0
],
}),
}),
}))
.
}))
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
.
Flatten
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master
-service
.json"
)
.
Flatten
()
.
Do
()
.
Watch
(
"1
0
"
)
Do
()
.
Watch
(
"1
2
"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
...
@@ -572,12 +572,12 @@ func TestWatch(t *testing.T) {
...
@@ -572,12 +572,12 @@ func TestWatch(t *testing.T) {
if
obj
.
Type
!=
watch
.
Added
{
if
obj
.
Type
!=
watch
.
Added
{
t
.
Fatalf
(
"unexpected watch event"
,
obj
)
t
.
Fatalf
(
"unexpected watch event"
,
obj
)
}
}
pod
,
ok
:=
obj
.
Object
.
(
*
api
.
Pod
)
service
,
ok
:=
obj
.
Object
.
(
*
api
.
Service
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"unexpected object: %#v"
,
obj
)
t
.
Fatalf
(
"unexpected object: %#v"
,
obj
)
}
}
if
pod
.
Name
!=
"foo"
||
pod
.
ResourceVersion
!=
"10
"
{
if
service
.
Name
!=
"baz"
||
service
.
ResourceVersion
!=
"12
"
{
t
.
Errorf
(
"unexpected
pod: %#v"
,
pod
)
t
.
Errorf
(
"unexpected
service: %#v"
,
service
)
}
}
}
}
}
}
...
@@ -585,8 +585,8 @@ func TestWatch(t *testing.T) {
...
@@ -585,8 +585,8 @@ func TestWatch(t *testing.T) {
func
TestWatchMultipleError
(
t
*
testing
.
T
)
{
func
TestWatchMultipleError
(
t
*
testing
.
T
)
{
_
,
err
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
_
,
err
:=
NewBuilder
(
latest
.
RESTMapper
,
api
.
Scheme
,
fakeClient
())
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
.
NamespaceParam
(
"test"
)
.
DefaultNamespace
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
.
Flatten
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master
-controller
.json"
)
.
Flatten
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master.json"
)
.
Flatten
()
.
FilenameParam
(
"../../../examples/guestbook/redis-master
-controller
.json"
)
.
Flatten
()
.
Do
()
.
Watch
(
""
)
Do
()
.
Watch
(
""
)
if
err
==
nil
{
if
err
==
nil
{
...
...
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