Key value parameter maps to take array as value
Allow arrays to be specified as values in location_cfg_{prepend,append} and vhost_cfg_{ssl_,}{prepend,append} parameters.
This commit is contained in:
parent
fb560784e8
commit
04e34dce39
12 changed files with 131 additions and 54 deletions
|
@ -44,11 +44,12 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered prepended directives',
|
||||
:attr => 'location_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -90,10 +91,11 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
:attr => 'location_cfg_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
|
@ -157,10 +159,11 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered prepended directives',
|
||||
:attr => 'location_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
|
@ -173,9 +176,11 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
:attr => 'location_cfg_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => ['test value 3a', 'test value 3b', 'test value 3c'] },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' allow test value 3a;',
|
||||
' allow test value 3b;',
|
||||
' allow test value 3c;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
|
@ -208,20 +213,22 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered prepended directives',
|
||||
:attr => 'location_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
],
|
||||
},
|
||||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
:attr => 'location_cfg_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
|
@ -253,11 +260,12 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered prepended directives',
|
||||
:attr => 'location_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
' allow test value 3;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -299,11 +307,12 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
:attr => 'location_cfg_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
],
|
||||
},
|
||||
].each do |param|
|
||||
|
@ -346,11 +355,12 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered prepended directives',
|
||||
:attr => 'location_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -386,10 +396,11 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
:attr => 'location_cfg_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
|
@ -441,10 +452,11 @@ describe 'nginx::resource::location' do
|
|||
{
|
||||
:title => 'should contain ordered config directives',
|
||||
:attr => 'location_custom_cfg',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
|
|
|
@ -130,10 +130,11 @@ describe 'nginx::resource::vhost' do
|
|||
{
|
||||
:title => 'should contain ordered prepended directives',
|
||||
:attr => 'vhost_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test1 test value 1a;',
|
||||
' test1 test value 1b;',
|
||||
' test2 test value 2;',
|
||||
],
|
||||
},
|
||||
|
@ -218,11 +219,12 @@ describe 'nginx::resource::vhost' do
|
|||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
:attr => 'vhost_cfg_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -383,6 +385,28 @@ describe 'nginx::resource::vhost' do
|
|||
:value => '/path/to/error.log',
|
||||
:match => ' error_log /path/to/error.log;',
|
||||
},
|
||||
{
|
||||
:title => 'should contain ordered prepend directives',
|
||||
:attr => 'vhost_cfg_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
]
|
||||
},
|
||||
{
|
||||
:title => 'should contain ordered ssl prepend directives',
|
||||
:attr => 'vhost_cfg_ssl_prepend',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
]
|
||||
},
|
||||
{
|
||||
:title => 'should set root',
|
||||
:attr => 'use_default_location',
|
||||
|
@ -436,6 +460,17 @@ describe 'nginx::resource::vhost' do
|
|||
' test2 test value 2;',
|
||||
]
|
||||
},
|
||||
{
|
||||
:title => 'should contain ordered ssl appended directives',
|
||||
:attr => 'vhost_cfg_ssl_append',
|
||||
:value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' },
|
||||
:match => [
|
||||
' allow test value 3;',
|
||||
' test1 test value 1;',
|
||||
' test2 test value 2a;',
|
||||
' test2 test value 2b;',
|
||||
]
|
||||
},
|
||||
{
|
||||
:title => 'should contain www to non-www rewrite',
|
||||
:attr => 'rewrite_www_to_non_www',
|
||||
|
|
|
@ -5,10 +5,10 @@ include <%= file %>;
|
|||
<%# exists) to be first in the output order. The hash keys also need to be -%>
|
||||
<%# sorted so that the ordering is stable. -%>
|
||||
<% if @vhost_cfg_append -%><% @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
}
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @rewrite_www_to_non_www -%>
|
||||
server {
|
||||
listen <%= @listen_ip %>:<%= @listen_port %>;
|
||||
|
|
|
@ -18,7 +18,9 @@ server {
|
|||
<%# exists) to be first in the output order. The hash keys also need to be -%>
|
||||
<%# sorted so that the ordering is stable. -%>
|
||||
<% if @vhost_cfg_prepend -%><% @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @root -%>
|
||||
root <%= @root %>;
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
alias <%= @location_alias %>;
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
<%= value %>
|
||||
<% end -%><% end -%>
|
||||
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if defined? @www_root -%>
|
||||
root <%= @www_root %>;
|
||||
|
@ -33,7 +35,9 @@
|
|||
auth_basic_user_file <%= @auth_basic_user_file %>;
|
||||
<% end -%>
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
|
||||
<%= value %>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_custom_cfg -%><% @location_custom_cfg.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%>
|
||||
<%= value %>
|
||||
|
@ -20,7 +22,9 @@
|
|||
fastcgi_param SCRIPT_FILENAME <%= @fastcgi_script %>;
|
||||
<% end -%>
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
|
||||
<%= value %>
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
<%= value %>
|
||||
<% end -%><% end -%>
|
||||
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @proxy_cache -%>
|
||||
proxy_cache <%= @proxy_cache %>;
|
||||
|
@ -27,7 +29,9 @@
|
|||
rewrite <%= rewrite_rule %>;
|
||||
<% end -%>
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
|
||||
<%= value %>
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
stub_status on;
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
include <%= file %>;
|
||||
<% end -%><% end -%>
|
||||
<% if @vhost_cfg_append -%><% @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @vhost_cfg_ssl_append -%><% @vhost_cfg_ssl_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
}
|
||||
<% if @rewrite_www_to_non_www -%>
|
||||
server {
|
||||
|
|
|
@ -49,10 +49,14 @@ server {
|
|||
error_log <%= @ssl_error_log %>;
|
||||
|
||||
<% if @vhost_cfg_prepend -%><% @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @vhost_cfg_ssl_prepend -%><% @vhost_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% Array(value).each do |sub| -%>
|
||||
<%= key %> <%= sub %>;
|
||||
<% end %>
|
||||
<% end -%><% end -%>
|
||||
<% if @root -%>
|
||||
root <%= @root %>;
|
||||
|
|
Loading…
Reference in a new issue