Skip to content

Commit

Permalink
Merge pull request #1268 from bryangwilliam/custom_mime_types
Browse files Browse the repository at this point in the history
allow adding custom mime types while still using the module defaults
  • Loading branch information
bastelfreak committed Oct 24, 2018
2 parents c832536 + eaeaa3d commit ae2af80
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
12 changes: 12 additions & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,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
{
Expand Down
2 changes: 1 addition & 1 deletion templates/conf.d/mime.types.epp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET
types {
<% $nginx::mime_types.each |$key, $value| { -%>
<% $nginx::config::mime_types.each |$key, $value| { -%>
<%= $key %> <%= $value %>;
<% } -%>
}

0 comments on commit ae2af80

Please sign in to comment.