Skip to content

Commit

Permalink
Merge pull request voxpupuli#1094 from walkamongus/optional_index_files
Browse files Browse the repository at this point in the history
Allow index_files => undef in resource::server class
  • Loading branch information
wyardley committed Jul 11, 2017
2 parents 50815e4 + c3dbc1b commit 4370f81
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
Optional[String] $uwsgi = undef,
Optional[String] $uwsgi_params = "${nginx::config::conf_dir}/uwsgi_params",
Optional[String] $uwsgi_read_timeout = undef,
Array $index_files = [
Optional[Array] $index_files = [
'index.html',
'index.htm',
'index.php'],
Expand Down
24 changes: 24 additions & 0 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@
attr: 'error_pages',
value: { '503' => '/foo.html' },
match: ' error_page 503 /foo.html;'
},
{
title: 'should set index_file(s)',
attr: 'index_files',
value: %w(name1 name2),
match: %r{\s*index\s+name1\s+name2;}
},
{
title: 'should not set index_file(s)',
attr: 'index_files',
value: :undef,
match: %r{^((?!index).)*$}
}
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
Expand Down Expand Up @@ -733,6 +745,18 @@
attr: 'use_default_location',
value: true,
notmatch: %r{ root /;}
},
{
title: 'should set index_file(s)',
attr: 'index_files',
value: %w(name1 name2),
match: %r{\s*index\s+name1\s+name2;}
},
{
title: 'should not set index_file(s)',
attr: 'index_files',
value: :undef,
match: %r{^((?!index).)*$}
}
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
Expand Down
2 changes: 1 addition & 1 deletion templates/server/server_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ server {
<% if @ssl_redirect -%>
return 301 https://$host<% if @_ssl_redirect_port.to_i != 443 %>:<%= @_ssl_redirect_port %><% end %>$request_uri;
<% end -%>
<% if @index_files.count > 0 and not @ssl_only -%>
<% if @index_files and @index_files.count > 0 and not @ssl_only -%>
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;

<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion templates/server/server_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ server {
<% if defined? @gzip_types -%>
gzip_types <%= @gzip_types %>;
<% end -%>
<% if @index_files.count > 0 -%>
<% if @index_files and @index_files.count > 0 -%>
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;

<% end -%>
Expand Down

0 comments on commit 4370f81

Please sign in to comment.