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

Rewrite validate_domain_name() as a Puppet 4.x function #1345

Merged
merged 1 commit into from
May 4, 2023

Conversation

smortex
Copy link
Collaborator

@smortex smortex commented Apr 28, 2023

The 3.x function rely on is_domain_name() which is deprecated. Rewrite it using the more modern puppet 4.x function to rely on data types for better parameters validation.

While here, adjust the Stdlib::Fqdn / Stdlib::Host data types to test fully numerical addresses and add a Stdlib::Dns::Zonedata type that is basically the same but with a trailing dot.

@puppet-community-rangefinder
Copy link

validate_domain_name is a function

that may have no external impact to Forge modules.

validate_domain_name is a function

that may have no external impact to Forge modules.

This module is declared in 318 of 580 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.

@smortex smortex force-pushed the validate_domain_name branch from 5d200e2 to 0d72dcf Compare April 28, 2023 02:52
@smortex smortex marked this pull request as ready for review April 28, 2023 02:56
@smortex smortex requested review from a team, alexjfisher, b4ldr, bastelfreak and ekohl as code owners April 28, 2023 02:56
@@ -5,7 +5,6 @@
describe 'validate_domain_name' do
describe 'signature validation' do
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a change: before calling the function without parameters caused an exception, but now it pass (I would have assumed repeated_param was one or more but it seems to allow 0 values).

While we can add some code to make match the old behavior, it seems overkill and I decided to just ignore this corner case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I addressed this in #1351.

types/fqdn.pp Outdated Show resolved Hide resolved
types/dns_zone.pp Outdated Show resolved Hide resolved
spec/type_aliases/fqdn_spec.rb Outdated Show resolved Hide resolved
types/fqdn.pp Outdated Show resolved Hide resolved
b4ldr
b4ldr previously approved these changes Apr 28, 2023
Copy link
Collaborator

@b4ldr b4ldr left a comment

Choose a reason for hiding this comment

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

LGTM excluding the namespacing comments

types/dns_zone.pp Outdated Show resolved Hide resolved
bastelfreak
bastelfreak previously approved these changes Apr 29, 2023
The 3.x function rely on is_domain_name() which is deprecated. Rewrite
it using the more modern puppet 4.x function to rely on data types for
better parameters validation.

While here, adjust the Stdlib::Fqdn / Stdlib::Host data types to test
fully numerical addresses and add a Stdlib::Dns::Zonedata type that is
basically the same but with a trailing dot.
@smortex smortex force-pushed the validate_domain_name branch from 4a0b112 to c76f505 Compare May 3, 2023 18:53
@smortex
Copy link
Collaborator Author

smortex commented May 3, 2023

I just realized the PR description and the commit message where not in sync with the updated code. I force-pushed to fix the commit message. Sorry for the inconvenience!

@binford2k binford2k deleted the validate_domain_name branch May 4, 2023 19:14
smortex added a commit that referenced this pull request May 4, 2023
In #1345, the validate_domain_name() function was rewritten to the
Puppet 4.x syntax, but the behaviour was slightly changed since we
previously did not allow passing no parameter at all.

Add code to assert as least one paramatter is passed to restore the
previous behavior and raise an error when called without parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stdlib::Fqdn type accepts ipv4 addresses, also allows truncated addresses
7 participants