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

Add support for multiple 'proxy_cache_valid' directives #788

Merged
merged 2 commits into from
Apr 12, 2016
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: 3 additions & 1 deletion manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@
validate_string($proxy_cache_use_stale)
}
if ($proxy_cache_valid != false) {
validate_string($proxy_cache_valid)
if !(is_array($proxy_cache_valid) or is_string($proxy_cache_valid)) {
fail('$proxy_cache_valid must be a string or an array or false.')
}
}
if ($proxy_method != undef) {
validate_string($proxy_method)
Expand Down
4 changes: 3 additions & 1 deletion manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@
validate_string($proxy_cache_use_stale)
}
if ($proxy_cache_valid != false) {
validate_string($proxy_cache_valid)
if !(is_array($proxy_cache_valid) or is_string($proxy_cache_valid)) {
fail('$proxy_cache_valid must be a string or an array or false.')
}
}
if ($proxy_method != undef) {
validate_string($proxy_method)
Expand Down
11 changes: 10 additions & 1 deletion spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,20 @@
:notmatch => /proxy_cache_valid\b/
},
{
:title => 'should set proxy_cache_valid',
:title => 'should set proxy_cache_valid when string',
:attr => 'proxy_cache_valid',
:value => 'value',
:match => /^\s+proxy_cache_valid\s+value;/,
},
{
:title => 'should set proxy_cache_valid when array of strings',
:attr => 'proxy_cache_valid',
:value => ['value1','value2'],
:match => [
/^\s+proxy_cache_valid\s+value1;/,
/^\s+proxy_cache_valid\s+value2;/,
]
},
{
:title => 'should not set proxy_cache',
:attr => 'proxy_cache',
Expand Down
6 changes: 4 additions & 2 deletions templates/vhost/locations/proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
<% if @proxy_cache -%>
proxy_cache <%= @proxy_cache %>;
<% end -%>
<% if @proxy_cache_valid -%>
proxy_cache_valid <%= @proxy_cache_valid %>;
<% if @proxy_cache_valid && Array(@proxy_cache_valid).size > 0 -%>
<%- Array(@proxy_cache_valid).each do |line| -%>
proxy_cache_valid <%= line %>;
<%- end -%>
<% end -%>
<% if @proxy_cache_use_stale -%>
proxy_cache_use_stale <%= @proxy_cache_use_stale %>;
Expand Down