From 0c79578c4455b767f477037bbf9ec9f6b652b5a5 Mon Sep 17 00:00:00 2001 From: Kilian Engelhardt Date: Tue, 27 Oct 2020 20:20:37 +0100 Subject: [PATCH 1/2] add '.flatten' to 'location_allow' in 'server/location_header.erb' This enables using nested arrays for configuring 'location_allow'. Mostly useful for configration using Hiera. --- templates/server/location_header.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/server/location_header.erb b/templates/server/location_header.erb index c4450fe6f..04516d002 100644 --- a/templates/server/location_header.erb +++ b/templates/server/location_header.erb @@ -16,7 +16,7 @@ expires <%= @expires %>; <% end -%> <% if @location_allow -%> - <%- @location_allow.each do |allow_rule| -%> + <%- @location_allow.flatten.each do |allow_rule| -%> allow <%= allow_rule %>; <%- end -%> <% end -%> From 5f03f1d1a30b6179c3591a0da061cd275efde026 Mon Sep 17 00:00:00 2001 From: Kilian Engelhardt Date: Wed, 28 Oct 2020 20:51:18 +0100 Subject: [PATCH 2/2] add test for using nested arrays to configure 'location_allow' --- spec/defines/resource_location_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index c6723e5d8..637e8b5f8 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -113,7 +113,7 @@ match: ' expires 33d;' }, { - title: 'should set location_allow', + title: 'should set location_allow (flat array)', attr: 'location_allow', value: %w[127.0.0.1 10.0.0.1], match: [ @@ -121,6 +121,17 @@ ' allow 10.0.0.1;' ] }, + { + title: 'should set location_allow (nested array)', + attr: 'location_allow', + value: %w[127.0.0.1 10.0.0.1 [127.0.0.2 10.0.0.2]], + match: [ + ' allow 127.0.0.1;', + ' allow 10.0.0.1;' + ' allow 127.0.0.2;', + ' allow 10.0.0.2;' + ] + }, { title: 'should set location_deny', attr: 'location_deny',