Skip to content

Commit

Permalink
Fix: Prevent error return code on void includes
Browse files Browse the repository at this point in the history
The include statement will return an error code 20 if no data is included.

Their is three ways to fix this:
   - boilerplate jinja2 around each includes
   - include a dummy file with at least a function that do nothing
   - a function that does nothing in the included files

I chose the third as I found that signaling to the user the effects of its
pillar configuration is a good thing.

I also refined the jinja2 around the copy-all include to take care of more
specific setups where an user could have disabled all dotfiles but is enabling
some specifically.
  • Loading branch information
seven beep committed Oct 2, 2024
1 parent be5f119 commit 26f0f84
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 1 deletion.
20 changes: 19 additions & 1 deletion copy-all.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>
SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if salt['pillar.get']('qusal:dotfiles:all', default=true) == true -%}
{%- if (
( salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
or salt['pillar.get']('qusal:dotfiles:dom0') == true
or salt['pillar.get']('qusal:dotfiles:git') == true
or salt['pillar.get']('qusal:dotfiles:gtk') == true
or salt['pillar.get']('qusal:dotfiles:net') == true
or salt['pillar.get']('qusal:dotfiles:pgp') == true
or salt['pillar.get']('qusal:dotfiles:sh') == true
or salt['pillar.get']('qusal:dotfiles:ssh') == true
or salt['pillar.get']('qusal:dotfiles:vim') == true
or salt['pillar.get']('qusal:dotfiles:x11') == true
or salt['pillar.get']('qusal:dotfiles:xfce') == true
)
-%}

include:
- .copy-dom0
Expand All @@ -20,6 +33,11 @@ include:
- .copy-x11
- .copy-xfce

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif -%}

{#
Expand Down
5 changes: 5 additions & 0 deletions copy-dom0.sls
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- makedirs: True
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-git.sls
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- recurse:
- mode
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-gtk.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-mutt.sls
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- makedirs: True
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-net.sls
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- keep_symlinks: True
- force_symlinks: True
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-pgp.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-sh.sls
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- recurse:
- mode
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-ssh.sls
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-tmux.sls
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- recurse:
- mode
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-vim.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-x11.sls
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- keep_symlinks: True
- force_symlinks: True
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}
5 changes: 5 additions & 0 deletions copy-xfce.sls
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- keep_symlinks: True
- force_symlinks: True
{%- else -%}
"{{ sls }}-is-deactivated":
test.nop
{%- endif %}

0 comments on commit 26f0f84

Please sign in to comment.