Skip to content

Commit

Permalink
This commit fixes the refresh_pattern template
Browse files Browse the repository at this point in the history
When using a regexp (when case_sensitive is set to false)
the -i should be placed BEFORE the $name and not after
Also fixed that no space was used between the max and
options field, added rspec for options
Removed default : which was used, this is not default,
changed README so ^ftp: has it mentioned
  • Loading branch information
ralfbosz committed Feb 20, 2018
1 parent c32476f commit 4cdfe85
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
23 changes: 21 additions & 2 deletions spec/defines/refresh_pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/squid.conf.refresh_pattern.erb
Original file line number Diff line number Diff line change
@@ -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 %>

0 comments on commit 4cdfe85

Please sign in to comment.