From c6ae81cc65b293744856309d23f51d085cbe069b Mon Sep 17 00:00:00 2001 From: N Date: Wed, 5 Jun 2019 22:35:46 +0100 Subject: [PATCH] refactor(pkgname): reserve 'pkg' as packaging dict BREAKING CHANGE: the parameter `pkg` is now a dictionary. References to `template.pkg` should be changed to `template.pkg.name`. --- pillar.example | 6 ++++-- template/defaults.yaml | 3 ++- template/osfamilymap.yaml | 12 ++++++++---- template/osfingermap.yaml | 3 ++- template/osmap.yaml | 6 ++++-- template/package/clean.sls | 2 +- template/package/install.sls | 2 +- test/integration/default/controls/config_spec.rb | 2 +- 8 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pillar.example b/pillar.example index ce073070..583a0d6f 100644 --- a/pillar.example +++ b/pillar.example @@ -12,11 +12,13 @@ template: # test the template formula itself. You should set these parameters to # examples that make sense in the contexto of the formula you're writing. {%- if grains.osfinger == 'CentOS-6' %} - pkg: cronie + pkg: + name: cronie service: name: crond {%- else %} - pkg: bash + pkg: + name: bash service: name: systemd-udevd {%- endif %} diff --git a/template/defaults.yaml b/template/defaults.yaml index a50346a2..8fec75f1 100644 --- a/template/defaults.yaml +++ b/template/defaults.yaml @@ -2,7 +2,8 @@ # vim: ft=yaml --- template: - pkg: template + pkg: + name: template rootgroup: root config: '/etc/template' service: diff --git a/template/osfamilymap.yaml b/template/osfamilymap.yaml index f4e14745..ee80e250 100644 --- a/template/osfamilymap.yaml +++ b/template/osfamilymap.yaml @@ -15,20 +15,24 @@ {%- endif %} Debian: - pkg: template-debian + pkg: + name: template-debian config: /etc/template.d/custom.conf RedHat: - pkg: template-redhat + pkg: + name: template-redhat config: /etc/template.conf Suse: - pkg: template-suse + pkg: + name: template-suse Gentoo: {} Arch: - pkg: template-arch + pkg: + name: template-arch service: name: service-arch diff --git a/template/osfingermap.yaml b/template/osfingermap.yaml index 3fa3235a..1789999c 100644 --- a/template/osfingermap.yaml +++ b/template/osfingermap.yaml @@ -16,6 +16,7 @@ Ubuntu-18.04: # os: CentOS CentOS-6: - pkg: template-centos-6 + pkg: + name: template-centos-6 config: /etc/template.d/custom-centos-6.conf CentOS-7: {} diff --git a/template/osmap.yaml b/template/osmap.yaml index 223197e3..f0c1ef9d 100644 --- a/template/osmap.yaml +++ b/template/osmap.yaml @@ -12,14 +12,16 @@ --- # os_family: Debian Ubuntu: - pkg: template-ubuntu + pkg: + name: template-ubuntu config: /etc/template.d/custom-ubuntu.conf Raspbian: {} # os_family: RedHat Fedora: - pkg: template-fedora + pkg: + name: template-fedora service: name: service-fedora diff --git a/template/package/clean.sls b/template/package/clean.sls index 8d2660f9..14a8cd0b 100644 --- a/template/package/clean.sls +++ b/template/package/clean.sls @@ -11,6 +11,6 @@ include: template-package-clean-pkg-removed: pkg.removed: - - name: {{ template.pkg }} + - name: {{ template.pkg.name }} - require: - sls: {{ sls_config_clean }} diff --git a/template/package/install.sls b/template/package/install.sls index 78bdb5ea..bc989667 100644 --- a/template/package/install.sls +++ b/template/package/install.sls @@ -7,4 +7,4 @@ template-package-install-pkg-installed: pkg.installed: - - name: {{ template.pkg }} + - name: {{ template.pkg.name }} diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/default/controls/config_spec.rb index d76c7f66..13b2c296 100644 --- a/test/integration/default/controls/config_spec.rb +++ b/test/integration/default/controls/config_spec.rb @@ -12,7 +12,7 @@ its('content') { should include '"added_in_lookup": "lookup_value"' } its('content') { should include '"config": "/etc/template-formula.conf"' } its('content') { should include '"lookup": {"added_in_lookup": "lookup_value",' } - its('content') { should include '"pkg": "' } + its('content') { should include '"pkg": {"name": "' } its('content') { should include '"service": {"name": "' } its('content') { should include '"tofs": {"files_switch": ["any/path/can/be/used/here", "id", "osfinger", "os", "os_family"], "source_files": {"template-config-file-file-managed": ["example.tmpl.jinja"]}' } its('content') { should include '"winner": "pillar"}' }