From eaeaa3de4637782d34ea8541b237903da97c49e7 Mon Sep 17 00:00:00 2001 From: Bryan Gwilliam Date: Sun, 21 Oct 2018 16:56:06 -0600 Subject: [PATCH] allow preserving the default mime_types in addition to provided values --- manifests/config.pp | 5 ++++- manifests/init.pp | 1 + spec/classes/nginx_spec.rb | 12 ++++++++++++ templates/conf.d/mime.types.epp | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 2d5d5e94d..968d73a97 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -83,7 +83,10 @@ $log_format = $nginx::log_format $mail = $nginx::mail $stream = $nginx::stream - $mime_types = $nginx::mime_types + $mime_types = $nginx::mime_types_preserve_defaults ? { + true => merge($nginx::params::mime_types,$nginx::mime_types), + default => $nginx::mime_types, + } $multi_accept = $nginx::multi_accept $names_hash_bucket_size = $nginx::names_hash_bucket_size $names_hash_max_size = $nginx::names_hash_max_size diff --git a/manifests/init.pp b/manifests/init.pp index c33d4f55a..4a72cf3c7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -149,6 +149,7 @@ $package_flavor = undef, Boolean $manage_repo = $nginx::params::manage_repo, Hash[String[1], String[1]] $mime_types = $nginx::params::mime_types, + Boolean $mime_types_preserve_defaults = false, Optional[String] $repo_release = undef, $passenger_package_ensure = 'present', ### END Package Configuration ### diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index b55f7eabb..ac1cdb60c 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -953,6 +953,18 @@ it { is_expected.to contain_file('/etc/nginx/mime.types').with_content(%r{audio/mpeg mp3;}) } end + context 'when mime.types is "[\'custom/file customfile\']" and mime.types.preserve.defaults is true' do + let(:params) do + { + mime_types: { 'custom/file' => 'customfile' }, + mime_types_preserve_defaults: true + } + end + + it { is_expected.to contain_file('/etc/nginx/mime.types').with_content(%r{audio/mpeg mp3;}) } + it { is_expected.to contain_file('/etc/nginx/mime.types').with_content(%r{custom/file customfile;}) } + end + context 'when dynamic_modules is "[\'ngx_http_geoip_module\']" ' do let(:params) do { diff --git a/templates/conf.d/mime.types.epp b/templates/conf.d/mime.types.epp index f71022ecb..d7a2c6c55 100644 --- a/templates/conf.d/mime.types.epp +++ b/templates/conf.d/mime.types.epp @@ -1,6 +1,6 @@ # MANAGED BY PUPPET types { -<% $nginx::mime_types.each |$key, $value| { -%> +<% $nginx::config::mime_types.each |$key, $value| { -%> <%= $key %> <%= $value %>; <% } -%> }