Skip to content

fix driver:local in prefixing volumes with current dir name #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/loader/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) {

if composeServiceConfig.Volumes != nil {
for _, volume := range composeServiceConfig.Volumes.Volumes {
serviceConfig.Volumes = append(serviceConfig.Volumes, volume.String())
v := normalizeServiceNames(volume.String())
serviceConfig.Volumes = append(serviceConfig.Volumes, v)
}
}

Expand Down
8 changes: 8 additions & 0 deletions script/test/cmd/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/te
# when kompose.service.expose="<hostname>" and multiple ports in docker compose file (first port should be selected)
convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname-multiple-ports.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/openshift-expose-hostname-multiple-ports.json"


# Test the change in the service name
# Kubernetes Test
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/service-name-change/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/service-name-change/output-k8s.json" "Unsupported root level volumes key - ignoring"
# Openshift Test
convert::expect_success_and_warning "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/service-name-change/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/service-name-change/output-os.json" "Unsupported root level volumes key - ignoring"


######
# Test the output file behavior of kompose convert
# Default behavior without -o
Expand Down
36 changes: 36 additions & 0 deletions script/test/fixtures/service-name-change/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '2'
services:
mariadb:
image: 'bitnami/mariadb:latest'
volumes:
- 'mariadb-data:/bitnami/mariadb'
environment:
- MARIADB_USER=bn_wordpress
- MARIADB_DATABASE=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
wordpress:
image: 'bitnami/wordpress:latest'
ports:
- '80:80'
- '443:443'
volumes:
- 'wordpress-data:/bitnami/wordpress'
- 'apache-data:/bitnami/apache'
- 'php-data:/bitnami/php'
depends_on:
- mariadb
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT=3306
- WORDPRESS_DATABASE_USER=bn_wordpress
- WORDPRESS_DATABASE_NAME=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
volumes:
mariadb-data:
driver: local
wordpress-data:
driver: local
apache-data:
driver: local
php-data:
driver: local
311 changes: 311 additions & 0 deletions script/test/fixtures/service-name-change/output-k8s.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "headless",
"port": 55555,
"targetPort": 0
}
],
"selector": {
"io.kompose.service": "mariadb"
},
"clusterIP": "None"
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "wordpress"
}
},
"spec": {
"ports": [
{
"name": "80",
"port": 80,
"targetPort": 80
},
{
"name": "443",
"port": 443,
"targetPort": 443
}
],
"selector": {
"io.kompose.service": "wordpress"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb"
}
},
"spec": {
"volumes": [
{
"name": "servicenamechange-mariadb-data",
"persistentVolumeClaim": {
"claimName": "servicenamechange-mariadb-data"
}
}
],
"containers": [
{
"name": "mariadb",
"image": "bitnami/mariadb:latest",
"env": [
{
"name": "MARIADB_USER",
"value": "bn_wordpress"
},
{
"name": "MARIADB_DATABASE",
"value": "bitnami_wordpress"
},
{
"name": "ALLOW_EMPTY_PASSWORD",
"value": "yes"
}
],
"resources": {},
"volumeMounts": [
{
"name": "servicenamechange-mariadb-data",
"mountPath": "/bitnami/mariadb"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {
"type": "Recreate"
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "servicenamechange-mariadb-data",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "servicenamechange-mariadb-data"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "wordpress"
}
},
"spec": {
"volumes": [
{
"name": "servicenamechange-wordpress-data",
"persistentVolumeClaim": {
"claimName": "servicenamechange-wordpress-data"
}
},
{
"name": "servicenamechange-apache-data",
"persistentVolumeClaim": {
"claimName": "servicenamechange-apache-data"
}
},
{
"name": "servicenamechange-php-data",
"persistentVolumeClaim": {
"claimName": "servicenamechange-php-data"
}
}
],
"containers": [
{
"name": "wordpress",
"image": "bitnami/wordpress:latest",
"ports": [
{
"containerPort": 80
},
{
"containerPort": 443
}
],
"env": [
{
"name": "MARIADB_HOST",
"value": "mariadb"
},
{
"name": "MARIADB_PORT",
"value": "3306"
},
{
"name": "WORDPRESS_DATABASE_USER",
"value": "bn_wordpress"
},
{
"name": "WORDPRESS_DATABASE_NAME",
"value": "bitnami_wordpress"
},
{
"name": "ALLOW_EMPTY_PASSWORD",
"value": "yes"
}
],
"resources": {},
"volumeMounts": [
{
"name": "servicenamechange-wordpress-data",
"mountPath": "/bitnami/wordpress"
},
{
"name": "servicenamechange-apache-data",
"mountPath": "/bitnami/apache"
},
{
"name": "servicenamechange-php-data",
"mountPath": "/bitnami/php"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {
"type": "Recreate"
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "servicenamechange-wordpress-data",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "servicenamechange-wordpress-data"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "servicenamechange-apache-data",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "servicenamechange-apache-data"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "servicenamechange-php-data",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "servicenamechange-php-data"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
}
]
}
Loading