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 refresh_pattern defined type #57

Merged
merged 1 commit into from
Jun 28, 2017
Merged

Add refresh_pattern defined type #57

merged 1 commit into from
Jun 28, 2017

Conversation

matonb
Copy link
Contributor

@matonb matonb commented Jun 27, 2017

Adds a defined type for Squid refresh_pattern configuration directive.

README.md Outdated

#### Parameters for Type squid::refresh_pattern
* `case_sensitive` Boolean value, if true (default) the regex is case sensitive, when false the case insensitive flag '-i' is added to the pattern
* `comment` Comment added before refresh rule, defaults to refresh_pattern fragement for `title`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'fragement' spelling

@@ -77,6 +78,9 @@
if $cache_dirs {
validate_hash($cache_dirs)
}
if $refresh_patterns {
validate_hash($refresh_patterns)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vox Pupuli are (slowly) getting round to replacing all calls to validate_x with puppet 4 data types.

$pattern = $title,
$comment = "refresh_pattern fragment for ${pattern}",
) {
validate_bool($case_sensitive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use puppet 4 data types instead of validate_x calls here?

$sslproxy_cert_error = $squid::params::sslproxy_cert_error,
$extra_config_sections = {},
String $access_log = $squid::params::access_log,
String $cache_mem = $squid::params::cache_mem,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to do something like

Pattern[/\d+ MB/] $cache_mem = $squid::params::cache_mem

here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look at adding the pattern to the parameter definition

@matonb
Copy link
Contributor Author

matonb commented Jun 28, 2017

@alexjfisher Added Pattern to params to replace the last couple of validate_re calls and updated memory_cache_shared to accept on/off or boolean value.

@@ -5,7 +5,7 @@
cache_mem <%= @cache_mem %>

<% if @memory_cache_shared -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a problem if the parameter has been set to the boolean false. Instead of memory_cache_shared 'off' you'll get nothing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this would need to be...

<% unless @memory_cache_shared.nil? -%>

??
Probably need a new spec test if you're going to include this change in this PR. Alternatively, it can be left as just a 'yes'/'no' Enum for now and someone could tackle accepting booleans in a separate PR.

@@ -5,7 +5,7 @@
cache_mem <%= @cache_mem %>

<% if @memory_cache_shared -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this would need to be...

<% unless @memory_cache_shared.nil? -%>

??
Probably need a new spec test if you're going to include this change in this PR. Alternatively, it can be left as just a 'yes'/'no' Enum for now and someone could tackle accepting booleans in a separate PR.

@matonb
Copy link
Contributor Author

matonb commented Jun 28, 2017

@alexjfisher I was wondering about that check in the template.

I'll update with .nil and see if it still works as expected.

@matonb
Copy link
Contributor Author

matonb commented Jun 28, 2017

@alexjfisher
Think the tests are Ok:

it { is_expected.to contain_concat_fragment('squid_header').without_content(%r{^memory_cache_shared}) }

it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^memory_cache_shared\s+on$}) }

Replaced untyped parameters in init.pp and refresh_pattern.pp with Puppet4 data types and removed validate_x function calls

Allow on / off string and boolean value for memory_cache_shared
@alexjfisher alexjfisher merged commit 3d18cfa into voxpupuli:master Jun 28, 2017
@alexjfisher
Copy link
Member

Merged. Thanks @matonb !

@matonb matonb deleted the feature/refresh_pattern branch June 29, 2017 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants