Skip to content

Commit 6cb486d

Browse files
Jonathon Andersonmyii
authored andcommitted
fix(snippets): ignore servers or snippets when undefined
nginx.servers_config wants a lightened copy of the nginx map to render as json; but, when it was trying to remove the servers and snippets keys from the map it assumed their presence, causing a KeyError if they were not present by its use of .pop(). While wrapping these in an "if" clause would likely be more correct, along with replacing .pop() with del (if jinja even supports that) the simplest change here is to just specify a default value for .pop(), which obviates the KeyError. Fixes #274
1 parent a55f741 commit 6cb486d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nginx/servers_config.sls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
{% set server_states = [] %}
1111
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
1212
{%- set _nginx = nginx.copy() %}
13-
{%- do _nginx.pop('snippets') %}
14-
{%- do _nginx.pop('servers') %}
13+
{%- do _nginx.pop('snippets') if nginx.snippets is defined %}
14+
{%- do _nginx.pop('servers') if nginx.servers is defined %}
1515
1616
# Simple path concatenation.
1717
# Needs work to make this function on windows.

nginx/snippets.sls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
99
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
1010
{%- set _nginx = nginx.copy() %}
11-
{%- do _nginx.pop('snippets') %}
12-
{%- do _nginx.pop('servers') %}
11+
{%- do _nginx.pop('snippets') if nginx.snippets is defined %}
12+
{%- do _nginx.pop('servers') if nginx.servers is defined %}
1313
1414
nginx_snippets_dir:
1515
file.directory:

0 commit comments

Comments
 (0)