Skip to content

Commit

Permalink
Allow setting a custom path for mime.types
Browse files Browse the repository at this point in the history
In certain environment the user may wish to use mime.types file from
a path other than $conf_dir
  • Loading branch information
jacksgt committed Mar 12, 2019
1 parent 36a6908 commit 5df3ca2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
$keepalive_requests = $nginx::keepalive_requests
$log_format = $nginx::log_format
$mail = $nginx::mail
$mime_types_path = $nginx::mime_types_path
$stream = $nginx::stream
$mime_types = $nginx::mime_types_preserve_defaults ? {
true => merge($nginx::params::mime_types,$nginx::mime_types),
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
$keepalive_requests = '100',
$log_format = {},
Boolean $mail = false,
Variant[String, Boolean] $mime_types_path = 'mime.types',
Boolean $stream = false,
String $multi_accept = 'off',
Integer $names_hash_bucket_size = 64,
Expand Down
8 changes: 7 additions & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,17 @@
context 'when conf_dir is /path/to/nginx' do
let(:params) { { conf_dir: '/path/to/nginx' } }

it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include /path/to/nginx/mime\.types;}) }
it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include mime\.types;}) }
it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include /path/to/nginx/conf\.d/\*\.conf;}) }
it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include /path/to/nginx/sites-enabled/\*;}) }
end

context 'when mime_types_path is /path/to/mime.types' do
let(:params) { { mime_types_path: '/path/to/mime.types' } }

it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(%r{include /path/to/mime\.types;}) }
end

context 'when confd_purge true' do
let(:params) { { confd_purge: true } }

Expand Down
4 changes: 3 additions & 1 deletion templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ http {
<%- end -%>
<%- end -%>
<% end -%>
include <%= @conf_dir %>/mime.types;
<% if @mime_types_path.is_a? String && @mime_types_path.empty? == false -%>
include <%= @mime_types_path %>;
<% end -%>
default_type application/octet-stream;
<% if @log_format -%>
<% @log_format.sort_by{|k,v| k}.each do |key,value| -%>
Expand Down

0 comments on commit 5df3ca2

Please sign in to comment.