diff --git a/README.md b/README.md index 39fc391..6a4e8a8 100644 --- a/README.md +++ b/README.md @@ -288,7 +288,7 @@ As an alternative to using the Squid::Http\_port defined type with `ssl` set to Defines [refresh_pattern entries](http://www.squid-cache.org/Doc/config/refresh_pattern/) for a squid server. ```puppet -squid::refresh_pattern { '^ftp': +squid::refresh_pattern { '^ftp:': min => 1440, max => 10080, percent => 20, @@ -310,7 +310,7 @@ would result in the following squid refresh patterns # refresh_pattern fragment for ^ftp refresh_pattern ^ftp: 1440 20% 10080 # refresh_pattern fragment for (/cgi-bin/|\?) -refresh_pattern (/cgi-bin/|\?): -i 0 0% 0 +refresh_pattern (/cgi-bin/|\?) -i 0 0% 0 ``` These may be defined as a hash passed to ::squid diff --git a/spec/defines/refresh_pattern_spec.rb b/spec/defines/refresh_pattern_spec.rb index a862412..79130c6 100644 --- a/spec/defines/refresh_pattern_spec.rb +++ b/spec/defines/refresh_pattern_spec.rb @@ -28,9 +28,28 @@ fname = 'squid_refresh_pattern_my_pattern' it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') } it { is_expected.to contain_concat_fragment(fname).with_order('45-06') } - it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+my_pattern:\s+1440\s+20%\s+10080$}) } + it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+my_pattern\s+1440\s+20%\s+10080$}) } end # context 'when parameters are set' + context 'when parameters are set and options' do + let(:title) { 'my_pattern' } + let(:params) do + { + order: '06', + max: 10_080, + min: 1440, + percent: 20, + options: 'override-expire ignore-no-cache', + comment: 'Refresh Patterns' + } + end + + fname = 'squid_refresh_pattern_my_pattern' + it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') } + it { is_expected.to contain_concat_fragment(fname).with_order('45-06') } + it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+my_pattern\s+1440\s+20%\s+10080\s+override-expire\s+ignore-no-cache$}) } + end + context 'when parameters are set and case insensitive' do let(:title) { 'case_insensitive' } let(:params) do @@ -47,7 +66,7 @@ fname = 'squid_refresh_pattern_case_insensitive' it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') } it { is_expected.to contain_concat_fragment(fname).with_order('45-07') } - it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+case_insensitive:\s+-i\s+0\s+0%\s+0$}) } + it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+-i\s+case_insensitive\s+0\s+0%\s+0$}) } end # context 'when parameters are set and case insensitive' end end diff --git a/templates/squid.conf.refresh_pattern.erb b/templates/squid.conf.refresh_pattern.erb index 50e1348..1b879fe 100644 --- a/templates/squid.conf.refresh_pattern.erb +++ b/templates/squid.conf.refresh_pattern.erb @@ -1,2 +1,2 @@ # <%= @comment %> -refresh_pattern <%= @pattern %>: <%= @case_sensitive?'':'-i ' %><%= @min %> <%= @percent %>% <%= @max %><%= @options ? @options:'' %> +refresh_pattern <%= @case_sensitive?'':'-i ' %><%= @pattern %> <%= @min %> <%= @percent %>% <%= @max %><% if @options != '' %> <%= @options %><% end %>