Skip to content

Commit

Permalink
feat(test/salt/pillar/top.sls): manage across formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Nov 16, 2021
1 parent 758f9c1 commit b6454d7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ ssf:
- test/integration/share/inspec.yml
- test/integration/share/README.md
- test/integration/share/libraries/system.rb
- test/salt/pillar/top.sls
- .gitignore
- .cirrus.yml
- .gitlab-ci.yml
Expand Down
7 changes: 5 additions & 2 deletions ssf/config/formulas.sls
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{#- Use shorter variables to make the code a little easier to follow #}
{%- set context = semrel_formula_specs.context %}
{%- set inspec_suites_kitchen = context.inspec_suites_kitchen %}
{%- set kitchen = context.kitchen %}
{%- set testing_freebsd = context.testing_freebsd %}
{%- set testing_openbsd = context.testing_openbsd %}
{%- set testing_windows = context.testing_windows %}
Expand Down Expand Up @@ -139,6 +140,7 @@ prepare-git-branch-for-{{ formula }}:
{#- Also: remove both `kitchen.vagrant.yml` files if relevant testing not active #}
{#- Also: remove both `kitchen.windows.yml` files if relevant testing not active #}
{#- Also: remove both Jinja libaries used for the new `map.jinja` if a v5+ `map.jinja` isn't involved #}
{#- Also: remove `test/salt/pillar/top.sls` if relevant configuration not active #}
{%- if (semrel_file == '.cirrus.yml' and not use_cirrus_ci) or
(semrel_file == '.github/workflows/kitchen.yml' and not use_github_actions) or
(semrel_file == 'formula/libsaltcli.jinja' and not use_libsaltcli) or
Expand All @@ -147,7 +149,8 @@ prepare-git-branch-for-{{ formula }}:
(semrel_file in ['.travis.yml'] and formula in ['ssf-formula']) or
(semrel_file.endswith('kitchen.vagrant.yml') and not testing_freebsd.active and not testing_openbsd.active and not testing_windows.active) or
(semrel_file.endswith('kitchen.windows.yml') and not testing_windows.active) or
(semrel_file in ['formula/libmapstack.jinja', 'formula/libmatchers.jinja'] and map_jinja.version < 5)
(semrel_file in ['formula/libmapstack.jinja', 'formula/libmatchers.jinja'] and map_jinja.version < 5) or
(semrel_file == 'test/salt/pillar/top.sls' and not kitchen.provisioner.top_sls)
%}
{%- set add_or_rm = ['rm', 'remove', 'absent'] %}
{#- Never remove `map.jinja` but only ever manage it if a v5+ `map.jinja` is involved #}
Expand Down Expand Up @@ -199,7 +202,7 @@ remove-previous-file-location-for-{{ formula }}-{{ dest_file }}:
gitlab: {{ context.git.gitlab | yaml }}
inspec_suites_kitchen: {{ inspec_suites_kitchen | yaml }}
inspec_suites_matrix: {{ context.inspec_suites_matrix | yaml }}
kitchen: {{ context.kitchen | yaml }}
kitchen: {{ kitchen | yaml }}
map_jinja: {{ map_jinja | yaml }}
platforms: {{ context.platforms | yaml }}
platforms_matrix: {{ context.platforms_matrix | yaml }}
Expand Down
2 changes: 2 additions & 0 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ssf_node_anchors:
- '/test/integration/**/libraries/system.rb': '@saltstack-formulas/ssf'
- '/test/integration/**/inspec.yml': '@saltstack-formulas/ssf'
- '/test/integration/**/README.md': '@saltstack-formulas/ssf'
- '/test/salt/pillar/top.sls': '@saltstack-formulas/ssf'
- '/.gitignore': '@saltstack-formulas/ssf'
- '/.cirrus.yml': '@saltstack-formulas/ssf'
- '/.gitlab-ci.yml': '@saltstack-formulas/ssf'
Expand Down Expand Up @@ -152,6 +153,7 @@ ssf_node_anchors:
# So if values for this are provided, `pillars` & `pillars_from_files`
# will not be rendered under any of the suites
pillars_from_directories: []
top_sls: []
verifier:
backend_cache: true
map_jinja:
Expand Down
1 change: 1 addition & 0 deletions ssf/files/default/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# vim: ft=yaml
---
{#- {%- from tplroot ~ "/libcontext.jinja" import format_context, format_kwargs, format_list with context %} #}
{#- Centralise duplication from here and `test/salt/pillar/top.sls` #}
{%- macro format_matcher(matcher_parent, width=10) %}
{%- filter indent(width) %}
{%- for mp in matcher_parent %}
Expand Down
29 changes: 29 additions & 0 deletions ssf/files/default/test/salt/pillar/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
{#- Centralise duplication from here and `kitchen.yml` #}
{%- macro format_matcher(matcher_parent, width=10) %}
{%- filter indent(width) %}
{%- for mp in matcher_parent %}
{%- for matcher, matcher_specs in mp.items() %}
'{{ matcher }}':
{%- for matcher_child in matcher_specs %}
{%- if matcher_child == '.' %}
{%- set matcher_child = semrel_formula %}
{%- elif matcher_child.startswith('.') %}
{%- set matcher_child = semrel_formula ~ matcher_child %}
{%- endif %}
{#- To allow comments interspersed the list, use `list_format` accordingly #}
{%- set list_format = '- ' %}
{%- if matcher_child.startswith('#') %}
{%- set list_format = '' %}
{%- endif %}
{{ list_format }}{{ matcher_child }}
{%- endfor %}
{%- endfor %}
{%- endfor %}
{%- endfilter %}
{%- endmacro %}
base:
{{- format_matcher(kitchen.provisioner.top_sls, width=2) }}
...
3 changes: 3 additions & 0 deletions ssf/formulas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ ssf_node_anchors:
# yamllint disable rule:line-length
test/integration/share/libraries/system.rb: &file__test__integration__share__libraries__system--rb
<<: *file_default
test/salt/pillar/top.sls: &file__test__salt__pillar__top--sls
<<: *file_default
template: 'jinja'
.gitignore: &file__--gitignore
<<: *file_default
.cirrus.yml: &file__--cirrus--yml
Expand Down

0 comments on commit b6454d7

Please sign in to comment.