Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
fix spacing issues in various templates
Browse files Browse the repository at this point in the history
Before this change, vhost_ssl_header would merge
"ssl" with any listen options, e.g.:
    listen       *:443 ssldefault;
when listen_options => 'default'.
  • Loading branch information
Matthew Haughton committed Nov 22, 2013
1 parent c8d9ad5 commit 4af2087
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 40 deletions.
46 changes: 22 additions & 24 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,32 @@
:value => 'my_location',
:match => ' location my_location {',
},
# TODO: fix in template so following matches
#{
# :title => 'should contain ordered prepended directives',
# :attr => 'location_cfg_prepend',
# :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
# :match => [
# ' allow test value 3;',
# ' test1 test value 1;',
# ' test2 test value 2;',
# ],
#},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
:match => [
' allow test value 3;',
' test1 test value 1;',
' test2 test value 2;',
],
},
{
:title => 'should set alias',
:attr => 'location_alias',
:value => 'value',
:match => ' alias value;',
},
#TODO: fix in template so following matches
#{
# :title => 'should contain ordered appended directives',
# :attr => 'location_cfg_append',
# :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
# :match => [
# ' allow test value 3; ',
# ' test1 test value 1; ',
# ' test2 test value 2; ',
# ],
#},
{
:title => 'should contain ordered appended directives',
:attr => 'location_cfg_append',
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
:match => [
' allow test value 3;',
' test1 test value 1;',
' test2 test value 2;',
],
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
let :default_params do { :location => 'location', :location_alias => 'location_alias_value', :vhost => 'vhost1' } end
Expand Down Expand Up @@ -247,7 +245,7 @@
:title => 'should set try_file(s)',
:attr => 'try_files',
:value => ['name1','name2'],
:match => ' try_files name1 name2 ;', #TODO
:match => ' try_files name1 name2;',
},
{
:title => 'should set fastcgi_params',
Expand Down Expand Up @@ -332,7 +330,7 @@
:title => 'should set try_file(s)',
:attr => 'try_files',
:value => ['name1','name2'],
:match => ' try_files name1 name2 ;', #TODO
:match => ' try_files name1 name2;',
},
{
:title => 'should set index_file(s)',
Expand Down
10 changes: 8 additions & 2 deletions spec/defines/resource_mailhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
:title => 'should set the IPv4 listen IP',
:attr => 'listen_ip',
:value => '127.0.0.1',
:match => ' listen 127.0.0.1:25 ;', #TODO
:match => ' listen 127.0.0.1:25;',
},
{
:title => 'should set the IPv4 listen port',
:attr => 'listen_port',
:value => '45',
:match => ' listen *:45 ;', #TODO
:match => ' listen *:45;',
},
{
:title => 'should set the IPv4 listen options',
Expand Down Expand Up @@ -83,6 +83,12 @@
:value => 'spdy',
:match => ' listen [::]:80 spdy ipv6only=on;',
},
{
:title => 'should not set the IPv6 listen options',
:attr => 'ipv6_listen_options',
:value => false,
:match => ' listen [::]:80 ipv6only=on;',
},
{
:title => 'should set servername(s)',
:attr => 'server_name',
Expand Down
4 changes: 1 addition & 3 deletions spec/defines/resource_upstream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
:match => [
' test1 test value 1;',
' test2 test value 2;',
#TODO: fix this output in the template; should be no trailing
#spaces
' test3 test value 3; ',
' test3 test value 3;',
],
},
{
Expand Down
9 changes: 7 additions & 2 deletions spec/defines/resource_vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,13 @@
:title => 'should set the IPv4 listen options',
:attr => 'listen_options',
:value => 'default',
#TODO: fix me in template
:match => ' listen *:443 ssldefault;',
:match => ' listen *:443 ssl default;',
},
{
:title => 'should not set the IPv4 listen options',
:attr => 'listen_options',
:value => false,
:match => ' listen *:443 ssl;',
},
# {
# :title => 'should enable IPv6',
Expand Down
3 changes: 2 additions & 1 deletion templates/conf.d/upstream.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
upstream <%= @name %> {
<% if @upstream_cfg_prepend -%><% upstream_cfg_prepend.sort_by{|k,v| k}.each do |key,value| %>
<%= key %> <%= value %>;<% end -%><% end -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
<% @members.each do |i| %>
server <%= i %>;<% end %>
}
4 changes: 2 additions & 2 deletions templates/mailhost/mailhost.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

server {
listen <%= listen_ip %>:<%= listen_port %> <% if @listen_options %><%= listen_options %><% end %>;
listen <%= listen_ip %>:<%= listen_port %><% if @listen_options %> <%= listen_options %><% end %>;
<% # check to see if ipv6 support exists in the kernel before applying %>
<% if ipv6_enable && (defined? @ipaddress6) %>
listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %> <% if @ipv6_listen_options %><%= ipv6_listen_options %><% end %> ipv6only=on;
listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %><% if @ipv6_listen_options %> <%= ipv6_listen_options %><% end %> ipv6only=on;
<% end %>
server_name <%= server_name.join(" ") %>;
protocol <%= protocol %>;
Expand Down
6 changes: 4 additions & 2 deletions templates/vhost/vhost_location_alias.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
location <%= @location %> {
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;<% end -%><% end -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
alias <%= @location_alias %>;
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;<% end -%><% end -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
}

2 changes: 1 addition & 1 deletion templates/vhost/vhost_location_directory.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
root <%= @www_root %>;
<% end -%>
<% if @try_files -%>
try_files <% @try_files.each do |try| -%> <%= try %> <% end -%>;
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
<% end -%>
<% if @index_files -%>
index <% @index_files.each do |i| %> <%= i %><% end %>;
Expand Down
2 changes: 1 addition & 1 deletion templates/vhost/vhost_location_fastcgi.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
fastcgi_split_path_info <%= @fastcgi_split_path %>;
<% end -%>
<% if @try_files -%>
try_files <% @try_files.each do |try| -%> <%= try %> <% end -%>;
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
<% end -%>
include <%= @fastcgi_params %>;
fastcgi_pass <%= @fastcgi %>;
Expand Down
4 changes: 2 additions & 2 deletions templates/vhost/vhost_ssl_header.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server {
listen <%= @listen_ip %>:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @listen_options %><%= @listen_options %><% end %>;
listen <%= @listen_ip %>:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<% if @ipv6_enable == 'true' && (defined? @ipaddress6) %>
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %> ipv6only=on;
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %> ipv6only=on;
<% end %>
server_name <%= @rewrite_www_to_non_www ? @name.gsub(/^www\./, '') : @server_name.join(" ") %>;

Expand Down

0 comments on commit 4af2087

Please sign in to comment.