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

Minor refactor of mailhost.pp #1397

Merged
merged 1 commit into from
Aug 29, 2020

Conversation

alexjfisher
Copy link
Member

  • Remove what looks like copy-n-pasted lines (copied from resource/server.pp ?)
  • Use Stdlib::Port instead of Integer

@puppet-community-rangefinder
Copy link

nginx::resource::mailhost is a type

that may have no external impact to Forge modules.

This module is declared in 11 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@@ -1,7 +1,5 @@
# define: nginx::resource::mailhost
#
# This definition creates a virtual host
Copy link
Member Author

Choose a reason for hiding this comment

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

No it doesn't...

@@ -122,22 +120,10 @@
String $proxy_pass_error_message = 'off',
Array $server_name = [$name]
) {

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 think the new whitespace lint plugin complains about this line

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

$root_group = $nginx::root_group
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to create a local variable here.

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

$root_group = $nginx::root_group

File {
Copy link
Member Author

Choose a reason for hiding this comment

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

There are no File resources in this manifest (and resource defaults like this are discouraged anyway)

mode => $nginx::global_mode,
}

$config_dir = "${nginx::conf_dir}/conf.mail.d"
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved these lines to after the other validation stuff.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I noticed similar things but held back refactoring :)

@@ -77,13 +75,13 @@
# }
#
define nginx::resource::mailhost (
Integer $listen_port,
Stdlib::Port $listen_port,
Copy link
Member

Choose a reason for hiding this comment

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

Since these are ports, you can drop the + 0 later on in the code. That used to be needed when it could have been a String.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@@ -77,13 +75,13 @@
# }
#
define nginx::resource::mailhost (
Integer $listen_port,
Stdlib::Port $listen_port,
Enum['absent', 'present'] $ensure = 'present',
Variant[Array[String], String] $listen_ip = '*',
Optional[String] $listen_options = undef,
Boolean $ipv6_enable = false,
Variant[Array[String], String] $ipv6_listen_ip = '::',
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if this should also be tightened. Not sure about the nginx spec for listening.

@@ -169,7 +158,7 @@
}

# Create SSL File Stubs if SSL is enabled
if ($ssl) {
if $ssl {
Copy link
Member

Choose a reason for hiding this comment

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

If you're removing these braces, do we also remove them around line 143?

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

LGTM.

@vox-pupuli-tasks
Copy link

Dear @alexjfisher, thanks for the PR!

This is Vox Pupuli Tasks, your friendly Vox Pupuli Github Bot. I noticed that your pull request has CI failures. Can you please have a look at the failing CI jobs?
If you need any help, you can reach out to us on our IRC channel voxpupuli on Freenode or our Slack channel voxpupuli at slack.puppet.com.
You can find my sourcecode at voxpupuli/vox-pupuli-tasks

* Remove what looks like copy-n-pasted lines (copied from resource/server.pp ?)
* Use `Stdlib::Port` instead of `Integer`
* Get rid of unneeded `+ 0` (which was needed to cast String's to
Integers)
@alexjfisher alexjfisher merged commit 9e06714 into voxpupuli:master Aug 29, 2020
@alexjfisher alexjfisher deleted the mailhost_cleanups branch August 29, 2020 17:28
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this pull request Oct 19, 2020
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