From 0a1dacf60515b44bb94990166ce66c94126421ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 30 Jun 2014 08:37:43 +0200 Subject: [PATCH] Allow using $http_cfg_append with list of lists It should be possible to include array of arrays in order to have duplicate configuration keys (when permitted), like: nginx::http_cfg_append: - [include, /etc/nginx/vhosts/*.ngx] - [include, /etc/nginx/vhosts/*/*.ngx] --- manifests/init.pp | 5 ++++- spec/classes/config_spec.rb | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index fb414a6..f1a1728 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -162,8 +162,11 @@ class nginx ( validate_string($proxy_buffers) validate_string($proxy_buffer_size) if ($http_cfg_append != false) { - validate_hash($http_cfg_append) + if !is_hash($http_cfg_append) or !is_array($http_cfg_append) { + fail('$http_cfg_append must be either a hash or array') + } } + validate_string($nginx_error_log) validate_string($http_access_log) validate_hash($nginx_upstreams) diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 902495e..3434079 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -204,7 +204,7 @@ describe 'nginx::config' do :notmatch => / proxy_cache_path \/path\/to\/proxy\.cache levels=1 keys_zone=d2:100m max_size=500m inactive=20m;/, }, { - :title => 'should contain ordered appended directives', + :title => 'should contain ordered appended directives from hash', :attr => 'http_cfg_append', :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, :match => [ @@ -213,6 +213,15 @@ describe 'nginx::config' do ' test2 test value 2;', ], }, + { + :title => 'should contain duplicate appended directives from list of hashes', + :attr => 'http_cfg_append', + :value => [[ 'allow', 'test value 1'], ['allow', 'test value 2' ]], + :match => [ + ' allow test value 1;', + ' allow test value 2;', + ], + }, { :title => 'should set pid', :attr => 'pid',