Skip to content
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

Fix unnecessary JINJA indentation in State files #316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions docker/compose/build.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-build:
module.run:
Expand All @@ -16,6 +16,6 @@ docker-compose-{{ service }}-build:
- service_names: {{ d.compose[service]['service_names'] }}
{%- endif %}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
4 changes: 2 additions & 2 deletions docker/compose/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include:
- {{ sls_compose_software_clean }}

{%- for name, container in d.compose.ng.items() %}
{%- for name, container in d.compose.ng.items() %}

docker-compose-ng-{{ container.container_name|d(name) }}-{{ loop.index }}-stopped:
docker_container.stopped:
Expand All @@ -23,4 +23,4 @@ docker-compose-ng-{{ container.image }}-{{ loop.index }}-absent:
- require_in:
- sls: {{ sls_compose_software_clean }}

{% endfor %}
{% endfor %}
12 changes: 6 additions & 6 deletions docker/compose/get.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-get:
module.run:
- name: dockercompose.get
- path: {{ d.compose[service]['path'] }}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
16 changes: 8 additions & 8 deletions docker/compose/kill.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-kill:
module.run:
- name: dockercompose.kill
- path: {{ d.compose[service]['path'] }}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
- service_names: {{ d.compose[service]['service_names'] }}
{%- endif %}
{%- endif %}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
160 changes: 80 additions & 80 deletions docker/compose/ng.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ include:
- docker.compose.software
- docker.networks

{%- for name, container in d.compose.ng.items() %}
{%- set id = container.container_name|d(name) %}
{%- set required_containers = [] %}
{%- set required_networks = [] %}
{%- for name, container in d.compose.ng.items() %}
{%- set id = container.container_name|d(name) %}
{%- set required_containers = [] %}
{%- set required_networks = [] %}

docker-compose-ng-{{ id }}-present:
docker_image.present:
- force: {{ d.misc.force_present }}
{%- if ':' in container.image %}
{%- set image = container.image.split(':',1) %}
{%- if ':' in container.image %}
{%- set image = container.image.split(':',1) %}
- name: {{ image[0] }}
- tag: {{ image[1] }}
{%- else %}
{%- else %}
- name: {{ container.image }}
{%- endif %}
{%- endif %}

docker-compose-ng-{{ id }}-running:
docker_container.running:
Expand All @@ -34,107 +34,107 @@ docker-compose-ng-{{ id }}-running:
- privileged: {{ container.privileged|default(False) }}
- interactive: {{ container.stdin_open|default(False) }}
- tty: {{ container.tty|default(False) }}
{%- if 'command' in container %}
{%- if 'command' in container %}
- command: {{ container.command }}
{%- endif %}
{%- if 'working_dir' in container %}
{%- endif %}
{%- if 'working_dir' in container %}
- working_dir: {{ container.working_dir }}
{%- endif %}
{%- if 'volume_driver' in container %}
{%- endif %}
{%- if 'volume_driver' in container %}
- volume_driver: {{ container.volume_driver }}
{%- endif %}
{%- if 'userns_mode' in container %}
{%- endif %}
{%- if 'userns_mode' in container %}
- userns_mode: {{ container.userns_mode }}
{%- endif %}
{%- if 'user' in container %}
{%- endif %}
{%- if 'user' in container %}
- user: {{ container.user }}
{%- endif %}
{%- if 'environment' in container and container.environment is iterable %}
{%- endif %}
{%- if 'environment' in container and container.environment is iterable %}
- environment:
{%- for variable, value in container.environment.items() %}
{%- for variable, value in container.environment.items() %}
- {{ variable }}: {{ value }}
{%- endfor %}
{%- endif %}
{%- if 'ports' in container and container.ports is iterable %}
{%- endfor %}
{%- endif %}
{%- if 'ports' in container and container.ports is iterable %}
- port_bindings:
{%- for port_mapping in container.ports %}
{%- if port_mapping is string %}
{%- set mapping = port_mapping.split(':',2) %}
{%- if mapping|length < 2 %}
{%- for port_mapping in container.ports %}
{%- if port_mapping is string %}
{%- set mapping = port_mapping.split(':',2) %}
{%- if mapping|length < 2 %}
- "{{ mapping[0] }}"
{%- elif mapping|length > 2 %}
{%- elif mapping|length > 2 %}
- "{{ mapping[0] }}:{{ mapping[1] }}:{{ mapping[-1] }}"
{%- else %}
{%- else %}
- "{{ mapping[0] }}:{{ mapping[-1] }}"
{%- endif %}
{%- elif port_mapping is mapping %}
- {{ port_mapping }}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'volumes' in container %}
{%- elif port_mapping is mapping %}
- {{ port_mapping }}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'volumes' in container %}
- binds:
{%- for bind in container.volumes %}
{%- set mapping = bind.rsplit(':', 1) %}
{%- if mapping|length > 1 %}
{%- for bind in container.volumes %}
{%- set mapping = bind.rsplit(':', 1) %}
{%- if mapping|length > 1 %}
- "{{ mapping[0] }}:{{ mapping[-1] }}"
{%- else %}
{%- else %}
- "{{ mapping[0] }}"
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'volumes_from' in container %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'volumes_from' in container %}
- volumes_from:
{%- for volume in container.volumes_from %}
{%- do required_containers.append(volume) %}
{%- for volume in container.volumes_from %}
{%- do required_containers.append(volume) %}
- {{ volume }}
{%- endfor %}
{%- endif %}
{%- if 'links' in container %}
{%- endfor %}
{%- endif %}
{%- if 'links' in container %}
- links:
{%- for link in container.links %}
{%- set name, alias = link.split(':',1) %}
{%- do required_containers.append(name) %}
{%- for link in container.links %}
{%- set name, alias = link.split(':',1) %}
{%- do required_containers.append(name) %}
{{ name }}: {{ alias }}
{%- endfor %}
{%- endif %}
{%- if 'networks' in container %}
{%- endfor %}
{%- endif %}
{%- if 'networks' in container %}
- networks:
{%- for network in container.networks %}
{%- do required_networks.append(network) %}
{%- for network in container.networks %}
{%- do required_networks.append(network) %}
- {{ network }}
{%- endfor %}
{%- endif %}
{%- if 'restart' in container %}
{%- set policy = container.restart.split(':',1) %}
{%- if policy|length < 2 %}
{%- endfor %}
{%- endif %}
{%- if 'restart' in container %}
{%- set policy = container.restart.split(':',1) %}
{%- if policy|length < 2 %}
- restart_policy: {{ policy[0] }}
{%- else %}
{%- else %}
- restart_policy: {{ policy[0] }}:{{ policy[-1] }}
{%- endif %}
{%- endif %}
{%- if 'devices' in container %}
{%- endif %}
{%- if 'devices' in container %}
- devices:
{%- for device in container.devices %}
{%- set mapping = device.rsplit(':', 1) %}
{%- if mapping|length > 1 %}
{%- for device in container.devices %}
{%- set mapping = device.rsplit(':', 1) %}
{%- if mapping|length > 1 %}
- "{{ mapping[0] }}:{{ mapping[-1] }}"
{%- else %}
{%- else %}
- "{{ mapping[0] }}"
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
- require:
- docker_image: docker-compose-ng-{{ id }}-present
{%- if required_containers is defined %}
{%- for containerid in required_containers %}
{%- if required_containers is defined %}
{%- for containerid in required_containers %}
- docker_image: docker-compose-ng-{{ id }}-present
{%- endfor %}
{%- endif %}
{%- if required_networks is defined %}
{%- for networkid in required_networks %}
{%- endfor %}
{%- endif %}
{%- if required_networks is defined %}
{%- for networkid in required_networks %}
- docker_network: docker-network-{{ networkid }}-present
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}

{% endfor %}
{% endfor %}
16 changes: 8 additions & 8 deletions docker/compose/pause.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-pause:
module.run:
- name: dockercompose.pause
- path: {{ d.compose[service]['path'] }}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
- service_names: {{ d.compose[service]['service_names'] }}
{%- endif %}
{%- endif %}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
12 changes: 6 additions & 6 deletions docker/compose/ps.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-ps:
module.run:
- name: dockercompose.ps
- path: {{ d.compose[service]['path'] }}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
16 changes: 8 additions & 8 deletions docker/compose/pull.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-pull:
module.run:
- name: dockercompose.pull
- path: {{ d.compose[service]['path'] }}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
- service_names: {{ d.compose[service]['service_names'] }}
{%- endif %}
{%- endif %}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
16 changes: 8 additions & 8 deletions docker/compose/restart.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}

{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}
{%- if 'applications' in d.compose and d.compose.applications %}
{%- for service in d.compose.applications|unique %}
{%- if 'path' in d.compose[service] and d.compose[service]['path'] %}

docker-compose-{{ service }}-restart:
module.run:
- name: dockercompose.restart
- path: {{ d.compose[service]['path'] }}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
{%- if 'services_names' in d.compose[service] and d.compose[service]['service_names'] is iterable %}
- service_names: {{ d.compose[service]['service_names'] }}
{%- endif %}
{%- endif %}

{% endif %}
{%- endfor %}
{%- endif %}
{% endif %}
{%- endfor %}
{%- endif %}
Loading