Merge pull request #929 from hangyan/fix-v2compose-pvc-size-error

Fix custom pvc size in v2 compose not working error
This commit is contained in:
Charlie Drage 2018-02-08 08:24:49 -05:00 committed by GitHub
commit f857afad1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 316 additions and 0 deletions

View File

@ -230,6 +230,7 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
// canonical "Custom Labels" handler
// Labels used to influence conversion of kompose will be handled
// from here for docker-compose. Each loader will have such handler.
serviceConfig.Labels = make(map[string]string)
for key, value := range composeServiceConfig.Labels {
switch key {
case "kompose.service.type":
@ -243,6 +244,8 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
serviceConfig.ExposeService = strings.ToLower(value)
case "kompose.service.expose.tls-secret":
serviceConfig.ExposeServiceTLS = value
default:
serviceConfig.Labels[key] = value
}
}
if serviceConfig.ExposeService == "" && serviceConfig.ExposeServiceTLS != "" {

View File

@ -149,6 +149,18 @@ cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-m
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/output-os-template.json > /tmp/output-os.json
convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/docker-compose.yml convert --stdout -j" "/tmp/output-os.json"
######
# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/named-volume
# kubernetes test
cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose.yml convert --stdout -j"
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/output-k8s-template.json > /tmp/output-k8s.json
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose.yml convert --stdout -j" "/tmp/output-k8s.json"
# openshift test
cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose.yml convert --stdout -j"
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/output-os-template.json > /tmp/output-os.json
convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose.yml convert --stdout -j" "/tmp/output-os.json"
######
# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/volumes-from

View File

@ -0,0 +1,10 @@
version: '2'
services:
db:
image: postgres:10.1
ports:
- "5432"
labels:
kompose.volume.size: 1Gi
volumes:
- db-data:/var/lib/postgresql/data

View File

@ -0,0 +1,120 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "db",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"kompose.volume.size": "1Gi"
}
},
"spec": {
"ports": [
{
"name": "5432",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"io.kompose.service": "db"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "db",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"kompose.volume.size": "1Gi"
}
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
}
},
"spec": {
"volumes": [
{
"name": "db-data",
"persistentVolumeClaim": {
"claimName": "db-data"
}
}
],
"containers": [
{
"name": "db",
"image": "postgres:10.1",
"ports": [
{
"containerPort": 5432
}
],
"resources": {},
"volumeMounts": [
{
"name": "db-data",
"mountPath": "/var/lib/postgresql/data"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {
"type": "Recreate"
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "db-data",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db-data"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
}
},
"status": {}
}
]
}

View File

@ -0,0 +1,171 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "db",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"kompose.volume.size": "1Gi"
}
},
"spec": {
"ports": [
{
"name": "5432",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"io.kompose.service": "db"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "db",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"kompose.volume.size": "1Gi"
}
},
"spec": {
"strategy": {
"type": "Recreate",
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"db"
],
"from": {
"kind": "ImageStreamTag",
"name": "db:10.1"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "db"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
}
},
"spec": {
"volumes": [
{
"name": "db-data",
"persistentVolumeClaim": {
"claimName": "db-data"
}
}
],
"containers": [
{
"name": "db",
"image": " ",
"ports": [
{
"containerPort": 5432
}
],
"resources": {},
"volumeMounts": [
{
"name": "db-data",
"mountPath": "/var/lib/postgresql/data"
}
]
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "db",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db"
}
},
"spec": {
"tags": [
{
"name": "10.1",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "postgres:10.1"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "db-data",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "db-data"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
}
},
"status": {}
}
]
}