Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove spurious ':' from refresh_pattern template #87

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %>