Skip to content

Commit dbb542c

Browse files
committed
fix(php/ng): don't iterate on string, make sure list is not string
1 parent a98aa7e commit dbb542c

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

php/ng/fpm/config.sls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
{% endif %}
1212
{% endfor %}
1313
14-
15-
{% if salt['pillar.get']('php:ng:version') is iterable %}
16-
{% for version in salt['pillar.get']('php:ng:version') %}
14+
{% set pillar_php_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
15+
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
16+
{% for version in pillar_php_ng_version %}
1717
{% set conf_settings = odict(php.lookup.fpm.defaults) %}
18-
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
18+
{% set first_version = pillar_php_ng_version[0]|string %}
1919
{% set ini = php.lookup.fpm.ini|replace(first_version, version) %}
2020
{% set conf = php.lookup.fpm.conf|replace(first_version, version) %}
2121
{% set pools = php.lookup.fpm.pools|replace(first_version, version) %}

php/ng/fpm/init.sls

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ include:
55
- php.ng.fpm.service
66
- php.ng.fpm.pools
77

8+
{% set pillar_php_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
89
extend:
910
php_fpm_service:
1011
service:
1112
- watch:
12-
{% if salt['pillar.get']('php:ng:version') is iterable %}
13-
{% for version in salt['pillar.get']('php:ng:version') %}
13+
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
14+
{% for version in pillar_php_ng_version %}
1415
- file: php_fpm_ini_config_{{ version }}
1516
- file: php_fpm_conf_config_{{ version }}
1617
{% endfor %}
@@ -20,8 +21,8 @@ extend:
2021
{% endif %}
2122
- require:
2223
- sls: php.ng.fpm.config
23-
{% if salt['pillar.get']('php:ng:version') is iterable %}
24-
{% for version in salt['pillar.get']('php:ng:version') %}
24+
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
25+
{% for version in pillar_php_ng_version %}
2526
php_fpm_ini_config_{{ version }}:
2627
file:
2728
- require:

php/ng/fpm/pools_config.sls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
{% endfor %}
1919
{% set state = 'php_fpm_pool_conf_' ~ loop.index0 %}
2020
21-
{% if salt['pillar.get']('php:ng:version') is iterable %}
21+
{% set pillar_php_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
22+
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
2223
{% set first_fpath = path_join(config.get('filename', pool), php.lookup.fpm.pools) %}
23-
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
24+
{% set first_version = pillar_php_ng_version[0]|string %}
2425
{% set fpath = first_fpath.replace(first_version, config.get('phpversion', '7.0')) %}
2526
{% else %}
2627
{% set fpath = path_join(config.get('filename', pool), php.lookup.fpm.pools) %}

php/ng/installed.jinja

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
{% set pkgs = [] %}
1111
{% set specials = [] %}
1212

13+
{% set pillar_php_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
1314
{% if pkginfo is iterable and pkginfo is not string %}
1415
{% for pkg in pkginfo %}
1516
{% if pkg is mapping %}
1617
{% do specials.append(pkg) %}
1718
{% else %}
1819
{% do pkgs.append(pkg) %}
19-
{% if salt['pillar.get']('php:ng:version') is iterable %}
20-
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
21-
{% for other_version in salt['pillar.get']('php:ng:version') %}
20+
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
21+
{% set first_version = pillar_php_ng_version[0]|string %}
22+
{% for other_version in pillar_php_ng_version %}
2223
{% set other_version_str = other_version|string %}
2324
{% do pkgs.append(pkg.replace(first_version, other_version_str)) %}
2425
{% endfor %}
@@ -27,9 +28,9 @@
2728
{% endfor %}
2829
{% else %}
2930
{% do pkgs.append(pkginfo) %}
30-
{% if salt['pillar.get']('php:ng:version') is iterable %}
31-
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
32-
{% for other_version in salt['pillar.get']('php:ng:version') %}
31+
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
32+
{% set first_version = pillar_php_ng_version[0]|string %}
33+
{% for other_version in pillar_php_ng_version %}
3334
{% set other_version_str = other_version|string %}
3435
{% do pkgs.append(pkginfo.replace(first_version, other_version_str)) %}
3536
{% endfor %}

php/ng/map.jinja

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
33

4-
{%- if salt['pillar.get']('php:ng:version') is iterable %}
5-
{%- set phpng_version = salt['pillar.get']('php:ng:version')[0]|string %}
4+
{% set pillar_php_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
5+
{%- if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
6+
{%- set phpng_version = pillar_php_ng_version[0]|string %}
67
{% else %}
7-
{%- set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %}
8+
{%- set phpng_version = pillar_php_ng_version|string %}
89
{% endif %}
910
{%- set freebsd_phpng_version = phpng_version.replace('.', '') %}
1011

0 commit comments

Comments
 (0)