add stdin_open, tty support, add tests, fix #344

This adds supports for stdin_open: bool and
tty: bool support for kubernetes and openshift
providers in kompose. This maps to the
template.Spec.Containers[0].Stdin and
template.Spec.Containers[0].TTY in Kubernets
world.

Also, added tests.

Fixes #344
This commit is contained in:
Shubham Minglani
2016-12-28 15:58:45 +05:30
parent 0370d66357
commit 6a151c6267
12 changed files with 464 additions and 2 deletions
+16
View File
@@ -119,6 +119,22 @@ convert::expect_success "kompose --file $KOMPOSE_ROOT/script/test/fixtures/keyon
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/envs | cut -d'=' -f1)
######
# Test related to "stdin_open: true" in docker-compose
# kubernetes test
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/stdin-true/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/stdin-true/output-k8s.json"
# openshift test
convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/stdin-true/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/stdin-true/output-oc.json"
######
# Test related to "tty: true" in docker-compose
# kubernetes test
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/tty-true/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/tty-true/output-k8s.json"
# openshift test
convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/tty-true/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/tty-true/output-oc.json"
# Test related to kompose.expose.service label in docker compose file to ensure that services are exposed properly
#kubernetes tests
# when kompose.service.expose="True"
+7
View File
@@ -0,0 +1,7 @@
version: "2"
services:
client:
image: registry.centos.org/centos/centos:7
ports:
- "1337"
stdin_open: true
+72
View File
@@ -0,0 +1,72 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"ports": [
{
"name": "1337",
"protocol": "TCP",
"port": 1337,
"targetPort": 1337
}
],
"selector": {
"service": "client"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "client",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"containers": [
{
"name": "client",
"image": "registry.centos.org/centos/centos:7",
"ports": [
{
"containerPort": 1337,
"protocol": "TCP"
}
],
"resources": {},
"stdin": true
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
]
}
+124
View File
@@ -0,0 +1,124 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"ports": [
{
"name": "1337",
"protocol": "TCP",
"port": 1337,
"targetPort": 1337
}
],
"selector": {
"service": "client"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"client"
],
"from": {
"kind": "ImageStreamTag",
"name": "client:7"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "client"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"containers": [
{
"name": "client",
"image": " ",
"ports": [
{
"containerPort": 1337,
"protocol": "TCP"
}
],
"resources": {},
"stdin": true
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "7",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "registry.centos.org/centos/centos:7"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
}
]
}
+7
View File
@@ -0,0 +1,7 @@
version: "2"
services:
client:
image: registry.centos.org/centos/centos:7
ports:
- "1337"
tty: true
+72
View File
@@ -0,0 +1,72 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"ports": [
{
"name": "1337",
"protocol": "TCP",
"port": 1337,
"targetPort": 1337
}
],
"selector": {
"service": "client"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "client",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"containers": [
{
"name": "client",
"image": "registry.centos.org/centos/centos:7",
"ports": [
{
"containerPort": 1337,
"protocol": "TCP"
}
],
"resources": {},
"tty": true
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
]
}
+124
View File
@@ -0,0 +1,124 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"ports": [
{
"name": "1337",
"protocol": "TCP",
"port": 1337,
"targetPort": 1337
}
],
"selector": {
"service": "client"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"client"
],
"from": {
"kind": "ImageStreamTag",
"name": "client:7"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "client"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "client"
}
},
"spec": {
"containers": [
{
"name": "client",
"image": " ",
"ports": [
{
"containerPort": 1337,
"protocol": "TCP"
}
],
"resources": {},
"tty": true
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "client",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "7",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "registry.centos.org/centos/centos:7"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
}
]
}