Merge pull request #18 from FraaJad/master
Multiple service constraints. Volumes logic in stack state. Added configs key to docker-compose.yml.
diff --git a/docker/client/service.sls b/docker/client/service.sls
index dbe6de8..18a925a 100644
--- a/docker/client/service.sls
+++ b/docker/client/service.sls
@@ -35,8 +35,9 @@
{%- if service.workdir is defined %} --workdir {{ service.workdir }}{%- endif %}
{%- if service.mode is defined %} --mode {{ service.mode }}{%- endif %}
{%- if service.endpoint is defined %} --endpoint-mode {{ service.endpoint }}{%- endif %}
- {%- if service.constraint is defined %} --constraint {{ service.constraint }}{%- endif %}
{%- if service.hostname is defined %} --hostname {{ service.hostname }}{%- endif %}
+ {%- if service.constraint is defined %} --constraint {{ service.constraint }}{%- endif %}
+ {%- for constraint in service.get('constraints', []) %} --constraint {{ constraint }}{%- endfor %}
{%- for name, volume in service.get('volume', {}).iteritems() %} --mount {% for key, value in volume.iteritems() %}{{ key }}={{ value }}{% if not loop.last %},{% endif %}{% endfor %}{%- endfor %}
{%- for param, value in service.get('restart', {}).iteritems() %} --restart-{{ param }} {{ value }}{%- endfor %}
{%- for param, value in service.get('update', {}).iteritems() %} --update-{{ param }} {{ value }}{%- endfor %}
diff --git a/docker/client/stack.sls b/docker/client/stack.sls
index 8533f9a..8bf7ae8 100644
--- a/docker/client/stack.sls
+++ b/docker/client/stack.sls
@@ -52,9 +52,11 @@
{%- set path = volume.split(':')[0] %}
{%- elif volume is mapping and volume.get('type', 'bind') == 'bind' %}
{%- set path = volume.source %}
+ {%- else %}
+ {%- set path = None %}
{%- endif %}
- {%- if path is defined %}
+ {%- if path != None and path not in compose.get('volume', {}).keys() %}
docker_{{ app }}_{{ name }}_volume_{{ path }}:
file.directory:
- name: {{ path }}
diff --git a/docker/files/docker-compose.yml b/docker/files/docker-compose.yml
index f120327..f1685f0 100644
--- a/docker/files/docker-compose.yml
+++ b/docker/files/docker-compose.yml
@@ -1,5 +1,10 @@
version: '{{ compose.version|default("3") }}'
+{%- if compose.config|default({}) %}
+configs:
+ {{ compose.config|yaml(False)|indent(2) }}
+{%- endif %}
+
services:
{%- for name, srv in service.iteritems() %}
{%- set env_file_set = False %}