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

BREAKING: Drop puppet 3 support. Replace validate_* calls with datatypes in location.pp #1050

Merged
merged 6 commits into from
Mar 23, 2017

Conversation

bastelfreak
Copy link
Member

No description provided.

@bastelfreak bastelfreak changed the title replace validate_* calls with datatypes in replace validate_* calls with datatypes in location.pp Mar 10, 2017
@bastelfreak bastelfreak self-assigned this Mar 10, 2017
String $server = undef,
Optional[String] $www_root = undef,
Optional[String] $autoindex = undef,
Optional[Array ]$index_files = [
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary whitespace

@@ -153,66 +153,65 @@
# }

define nginx::resource::location (
$ensure = present,
Enum['present', 'absent'] $ensure = present,
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary whitespace

Copy link
Member Author

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!

$location_custom_cfg = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
Optional[String] $proxy = undef,
Copy link
Contributor

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))

Optional[String] $auth_basic_user_file = undef,
Optional[String] $auth_request = undef,
Array $rewrite_rules = [],
Integer $priority = 500,
$mp4 = false,
$flv = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing type

@@ -153,66 +153,65 @@
# }

define nginx::resource::location (
$ensure = present,
Enum['present', 'absent'] $ensure = present,
$internal = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing type

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing type

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing type

Optional[String] $auth_basic_user_file = undef,
Optional[String] $auth_request = undef,
Array $rewrite_rules = [],
Integer $priority = 500,
$mp4 = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing type

if !is_integer($priority) {
fail('$priority must be an integer.')
}
validate_array($rewrite_rules)
if (($priority + 0) < 401) or (($priority + 0) > 599) {
Copy link
Contributor

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.

String $server = undef,
Optional[String] $www_root = undef,
Optional[String] $autoindex = undef,
Optional[Array ]$index_files = [
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

@vinzent
Copy link
Contributor

vinzent commented Mar 13, 2017

did you run the beaker acceptance tests? are the ok?

@bastelfreak
Copy link
Member Author

mhm beaker... https://gist.github.com/bastelfreak/947477bff061607dc797119189a008ac
it is somehow broken. I will take a look at this in the next days, but maybe needs some time. if anybody else wants to test this... feel free :)

Copy link
Contributor

@igalic igalic left a 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 = [],
Copy link
Contributor

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?

Copy link
Member Author

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,
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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

@bastelfreak bastelfreak merged commit 66b3523 into voxpupuli:master Mar 23, 2017
@bastelfreak bastelfreak deleted the puppet4 branch March 23, 2017 20:19
@alexjfisher alexjfisher changed the title replace validate_* calls with datatypes in location.pp BREAKING: Drop puppet 3 support. Replace validate_* calls with datatypes in location.pp Aug 1, 2017
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,
Copy link

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)

Copy link
Member

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)

cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this pull request Sep 13, 2019
replace validate_* calls with datatypes in location.pp
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this pull request Oct 19, 2020
replace validate_* calls with datatypes in location.pp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants