瀏覽代碼

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
tags/v2.7.2
Jonathon Anderson 3 年之前
父節點
當前提交
6cb486dbd2
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 4 行新增4 行删除
  1. +2
    -2
      nginx/servers_config.sls
  2. +2
    -2
      nginx/snippets.sls

+ 2
- 2
nginx/servers_config.sls 查看文件

@@ -10,8 +10,8 @@
{% set server_states = [] %}
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
{%- set _nginx = nginx.copy() %}
{%- do _nginx.pop('snippets') %}
{%- do _nginx.pop('servers') %}
{%- do _nginx.pop('snippets') if nginx.snippets is defined %}
{%- do _nginx.pop('servers') if nginx.servers is defined %}

# Simple path concatenation.
# Needs work to make this function on windows.

+ 2
- 2
nginx/snippets.sls 查看文件

@@ -8,8 +8,8 @@

{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
{%- set _nginx = nginx.copy() %}
{%- do _nginx.pop('snippets') %}
{%- do _nginx.pop('servers') %}
{%- do _nginx.pop('snippets') if nginx.snippets is defined %}
{%- do _nginx.pop('servers') if nginx.servers is defined %}

nginx_snippets_dir:
file.directory:

Loading…
取消
儲存