Skip to content

Commit

Permalink
refactor(jinja): depreciate/replacer two variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 22, 2020
1 parent 25a6883 commit 2f07675
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 22 deletions.
6 changes: 3 additions & 3 deletions mongodb/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ include:
- sls: {{ sls_service_clean }}
- sls: {{ sls_config_clean }}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
{%- set software = d.pkg[comp][name] %}
{%- set package = software.package_format %}
{%- if package in d.software_package_matrix %}
{%- if package in d.use_upstream %}
{#- PACKAGE CLEAN #}
{%- if package in software and software[package] is mapping %}
Expand All @@ -42,7 +42,7 @@ include:
- file: {{ formula }}-clean-prerequisites
file.absent:
- name: {{ software['path'] }}
{%- if d.wanted.upstream_repo %}
{%- if d.use_upstream == 'repo' %}
pkgrepo.absent:
- name: {{ d.pkg['repo']['name'] }}
{%- endif %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/alternatives/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{%- set formula = d.formula %}
{%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/alternatives/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include:
- {{ sls_software_install }}
{%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include:
- {{ sls_service_clean }}
- {{ sls_alternatives_clean }}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/environ.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
include:
- {{ sls_software_install }}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ include:
- require:
- sls: {{ sls_software_install }}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/users.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
5 changes: 2 additions & 3 deletions mongodb/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# vim: ft=yaml
---
mongodb:
software_component_matrix: ['database', 'gui', 'connectors']
software_package_matrix: ['archive', 'macapp', 'native']
components: ['database', 'gui', 'connectors'] # depreciate software_component_matrix
use_upstream: ['archive', 'macapp', 'repo'] # depreciate software_package_matrix
wanted:
database:
- mongod
Expand All @@ -12,7 +12,6 @@ mongodb:
firewall: false
selinux: false
disable_transparent_hugepages: true
upstream_repo: false
default:
user: mongodb
group: mongodb
Expand Down
6 changes: 3 additions & 3 deletions mongodb/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ include:
- pkg: {{ formula }}-install-prerequisites
- pip: {{ formula }}-install-prerequisites
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
{%- set software = d.pkg[comp][name] %}
{%- set package = software.package_format %}
{%- if package in d.software_package_matrix %}
{%- if package in d.use_upstream %}
{# DOWNLOAD NATIVE PACKAGE #}
Expand Down Expand Up @@ -76,7 +76,7 @@ include:
{#- NATIVE PACKAGE INSTALL #}
{%- if package == 'native' %}
{%- if d.wanted.upstream_repo and 'repo' in d.pkg and d.pkg.repo %}
{%- if d.use_upstream = 'repo' and 'repo' in d.pkg and d.pkg.repo %}
pkgrepo.managed:
{{- format_kwargs(d.pkg['repo']) }}
{%- endif %}
Expand Down
13 changes: 11 additions & 2 deletions mongodb/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@
)
%}

# depreciate two params
{%- if 'software_component_matrix' in d %}
{%- do d.update({ 'components': d.software_component_matrix %}
{%- endif %}
{%- if 'software_package_matrix' in d %}
{%- do d.update({ 'use_upstream': d.software_package_matrix %}
{%- endif %}

# build dict
{%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}

{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- set software = d.pkg[comp][name] %}
Expand All @@ -34,7 +43,7 @@
{%- set release = v.version.split('.')[0] ~ '.' ~ v.version.split('.')[1] %}
{%- set dir = '%s-%s'|format(name, v.version) %}
{%- set path = d.dir.archive ~ '/' ~ dir %}
{%- for package in d.software_package_matrix %}
{%- for package in d.use_upstream %}
{%- if package in v and v[package] %}
{%- set path = d.dir[package] if package == 'macapp' else path %}
{%- do software[package].update({'name': path}) %}
Expand Down
5 changes: 2 additions & 3 deletions mongodb/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ Arch:
Alpine: {}

Debian:
use_upstream: 'archive' # using 'repo' caused a conflict
wanted:
firewall: false
# package conflict occured when true
upstream_repo: false
pkg:
deps:
- curl
Expand Down Expand Up @@ -61,10 +60,10 @@ Debian:
skip_verify: false

RedHat:
use_upstream: 'repo'
wanted:
firewall: false # turned off for travis ci
selinux: false # turrned off for travs citrue
upstream_repo: true
default:
user: mongod
group: mongod
Expand Down
2 changes: 1 addition & 1 deletion mongodb/service/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
include:
- {{ sls_config_clean }}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/service/running.sls
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ include:
- enable: True
{%- endif %}
{%- for comp in d.software_component_matrix %}
{%- for comp in d.components %}
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
{%- for name,v in d.pkg[comp].items() %}
{%- if name in d.wanted[comp] %}
Expand Down

0 comments on commit 2f07675

Please sign in to comment.