Skip to content

Commit

Permalink
fix(coupling): allow docker install without compose (#298)
Browse files Browse the repository at this point in the history
* fix(compose): avoid rendering errors if not using compose

* fix(init): only install what is 'wanted'
  • Loading branch information
noelmcloughlin authored Sep 8, 2021
1 parent 299a1d0 commit aaedb00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
8 changes: 5 additions & 3 deletions docker/compose/software/binary/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- if grains.kernel|lower in ('linux',) %}
{%- if grains.kernel|lower in ('linux',) and 'path' in d.pkg.compose %}
{%- set sls_alternatives_clean = tplroot ~ '.software.alternatives.clean' %}
include:
Expand All @@ -16,9 +16,11 @@ docker-compose-archive-absent:
- {{ d.dir.tmp }}/docker-compose
- {{ d.pkg.compose.path }}
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.pkg.compose.commands|unique %}
{%- if 'commands' in d.pkg.compose %}
{%- for cmd in d.pkg.compose.commands|unique %}
- /usr/local/bin/{{ cmd }}
{%- endfor %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endif %}
17 changes: 9 additions & 8 deletions docker/compose/software/binary/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
{%- if grains.kernel|lower in ('linux',) %}
{%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
{%- if d.pkg.compose.use_upstream == 'binary' and 'binary' in d.pkg.compose %}
{%- set composer = d.pkg.compose %}
{%- if composer.use_upstream == 'binary' and 'binary' in composer and 'path' in composer %}
docker-compose-software-binary-install:
{%- if 'deps' in d.pkg and d.pkg.deps %}
Expand All @@ -26,12 +27,12 @@ docker-compose-software-binary-install:
- file: docker-compose-software-binary-install
{%- endif %}
file.managed:
- unless: test -x {{ d.pkg.compose.path }}/docker-compose
- name: {{ d.pkg.compose.path }}/docker-compose
- source: {{ d.pkg.compose.binary.source }}
- unless: test -x {{ composer.path }}/docker-compose
- name: {{ composer.path }}/docker-compose
- source: {{ composer.binary.source }}
- clean: {{ d.misc.clean }}
{%- if 'source_hash' in d.pkg.compose.binary and d.pkg.compose.binary.source_hash %}
- source_hash: {{ d.pkg.compose.binary.source_hash }}
{%- if 'source_hash' in composer.binary and composer.binary.source_hash %}
- source_hash: {{ composer.binary.source_hash }}
{%- else %}
- skip_verify: True
{%- endif %}
Expand All @@ -46,12 +47,12 @@ docker-compose-software-binary-install:
- mode
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.pkg.compose.commands|unique %}
{%- for cmd in composer.commands|unique %}
docker-compose-software-binary-install-symlink-{{ cmd }}:
file.symlink:
- name: /usr/local/bin/{{ cmd }}
- target: {{ d.pkg.compose.path }}/{{ cmd }}
- target: {{ composer.path }}/{{ cmd }}
- force: True
- onchanges:
- file: docker-compose-software-binary-install
Expand Down
10 changes: 8 additions & 2 deletions docker/init.sls
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- if d.wanted is iterable %}
include:
- .software
- .compose
{{ '- .software' if 'docker' in d.wanted else '' }}
{{ '- .compose' if 'compose' in d.wanted else '' }}
# .networks
# .containers
{%- endif %}

0 comments on commit aaedb00

Please sign in to comment.