-
-
Notifications
You must be signed in to change notification settings - Fork 881
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
BREAKING: Drop puppet 3 support. Replace validate_* calls with datatypes in location.pp #1050
Conversation
manifests/resource/location.pp
Outdated
String $server = undef, | ||
Optional[String] $www_root = undef, | ||
Optional[String] $autoindex = undef, | ||
Optional[Array ]$index_files = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary whitespace
manifests/resource/location.pp
Outdated
@@ -153,66 +153,65 @@ | |||
# } | |||
|
|||
define nginx::resource::location ( | |||
$ensure = present, | |||
Enum['present', 'absent'] $ensure = present, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah shit. somehow forogt to reformat. sorry!
manifests/resource/location.pp
Outdated
$location_custom_cfg = undef, | ||
$location_cfg_prepend = undef, | ||
$location_cfg_append = undef, | ||
Optional[String] $proxy = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary whitespace (for all param lines))
manifests/resource/location.pp
Outdated
Optional[String] $auth_basic_user_file = undef, | ||
Optional[String] $auth_request = undef, | ||
Array $rewrite_rules = [], | ||
Integer $priority = 500, | ||
$mp4 = false, | ||
$flv = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing type
manifests/resource/location.pp
Outdated
@@ -153,66 +153,65 @@ | |||
# } | |||
|
|||
define nginx::resource::location ( | |||
$ensure = present, | |||
Enum['present', 'absent'] $ensure = present, | |||
$internal = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing type
manifests/resource/location.pp
Outdated
Optional[Variant[String, Array]] $raw_append = undef, | ||
Optional[Hash] $location_custom_cfg = undef, | ||
Optional[Hash] $location_cfg_prepend = undef, | ||
Optional[Hash] $location_cfg_append = undef, | ||
$location_custom_cfg_prepend = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing type
manifests/resource/location.pp
Outdated
Optional[Variant[String, Array]] $raw_append = undef, | ||
Optional[Hash] $location_custom_cfg = undef, | ||
Optional[Hash] $location_cfg_prepend = undef, | ||
Optional[Hash] $location_cfg_append = undef, | ||
$location_custom_cfg_prepend = undef, | ||
$location_custom_cfg_append = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing type
manifests/resource/location.pp
Outdated
Optional[String] $auth_basic_user_file = undef, | ||
Optional[String] $auth_request = undef, | ||
Array $rewrite_rules = [], | ||
Integer $priority = 500, | ||
$mp4 = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing type
manifests/resource/location.pp
Outdated
if !is_integer($priority) { | ||
fail('$priority must be an integer.') | ||
} | ||
validate_array($rewrite_rules) | ||
if (($priority + 0) < 401) or (($priority + 0) > 599) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the integer data types accepts min max params: https://docs.puppet.com/puppet/4.9/lang_data_number.html#the-integer-data-type
this conditional can be directly specified with the param type.
manifests/resource/location.pp
Outdated
String $server = undef, | ||
Optional[String] $www_root = undef, | ||
Optional[String] $autoindex = undef, | ||
Optional[Array ]$index_files = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace inside [] but not after.
@@ -904,18 +904,6 @@ | |||
it { is_expected.to contain_nginx__resource__location("#{title}-default").with_ssl_only(true) } | |||
end | |||
|
|||
context 'SSL cert missing' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is legacy about the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the datatypes enforce the correct param, so we don't need to test wrong/missing parameter. We dropped these kinds of tests on all other puppet4 only modules as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping the tests is easier than fixing them, but what's testing that you've correctly chosen the right data types when refactoring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should be handled by the reviewer + the existing tests. They will fail when wrong datatypes are supplied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there are other tests. I don't have massively strong feelings though. It was more devil's advocate. They probably are more trouble than they're worth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. In general we need more tests. but this is more of a global issue on all of our modules.
did you run the beaker acceptance tests? are the ok? |
mhm beaker... https://gist.github.com/bastelfreak/947477bff061607dc797119189a008ac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very happy with these changes
and… i have no idea what's up with beaker ☹
Optional[String] $auth_basic = undef, | ||
Optional[String] $auth_basic_user_file = undef, | ||
Optional[String] $auth_request = undef, | ||
Array $rewrite_rules = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how come this isn't Optional
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was already an existing array. I didn't want to change the datatype to undef and make it optional.
Enum['present', 'absent'] $ensure = present, | ||
Boolean $internal = false, | ||
String $location = $name, | ||
String $server = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does defaulting to undef
make sense if you're not using Optional[String]
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that makes it a required parameter. It currently already is a required param, just not handled nicely:
https://github.com/voxpupuli/puppet-nginx/blob/master/manifests/resource/location.pp#L385-L387
https://github.com/voxpupuli/puppet-nginx/blob/master/manifests/resource/location.pp#L230-L232
It would have been more clear if it didn't default to undef but to nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, old code does look a bit funky. Do you want to remove the default then since now it is much more obvious it provides no value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the best practice is. in the other PRs we tried to always default to undef on required params without default value
Optional[Hash] $location_cfg_prepend = undef, | ||
Optional[Hash] $location_cfg_append = undef, | ||
Optional[Hash] $location_custom_cfg_prepend = undef, | ||
Optional[Hash] $location_custom_cfg_append = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably have been Optional[Variant[Hash, Array]]
to match existing behaviour (#1100)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, but maybe not. See #1100 (comment)
replace validate_* calls with datatypes in location.pp
replace validate_* calls with datatypes in location.pp
No description provided.