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

Modernise fqdn_rotate function #1341

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

alexjfisher
Copy link
Collaborator

Convert the function to the modern function API as a namespaced function and use the networking fact instead of legacy facts.

A non-namespaced shim is also created (but marked deprecated), to preserve compatibility.

Along with #1326 this is the other half of the fix for #1315

@alexjfisher alexjfisher requested review from a team, b4ldr, bastelfreak, ekohl and smortex as code owners April 26, 2023 12:08
@puppet-community-rangefinder
Copy link

fqdn_rotate is a function

that may have no external impact to Forge modules.

stdlib::fqdn_rotate is a function

that may have no external impact to Forge modules.

fqdn_rotate 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.

@@ -68,9 +66,9 @@ def fqdn_rotate(value, args = {})

# workaround not being able to use let(:facts) because some tests need
# multiple different hostnames in one context
allow(scope).to receive(:lookupvar).with('::fqdn').and_return(host)
allow(subject.func.closure_scope).to receive(:[]).with('facts').and_return({ 'networking' => { 'fqdn' => host } })
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What I really wanted to do was mock the function's private method fqdn_fact, but can't figure out how to do this.

@alexjfisher alexjfisher force-pushed the modernise_fqdn_rotate branch from 945bb0f to f2f6635 Compare April 26, 2023 16:27
bastelfreak
bastelfreak previously approved these changes Apr 26, 2023
b4ldr
b4ldr previously approved these changes Apr 27, 2023
@LukasAud
Copy link
Contributor

Hey @alexjfisher, looks like there are some conflicts in the branch that need to be addressed before this can be merged. If you can get this sorted, the PR should be mergeable right away.

@ic248
Copy link

ic248 commented Aug 8, 2023

Any progress with this PR, with the latest version we're currently still seeing lots of changes on each Puppet run as mentioned in #1381

Copy link
Collaborator

@smortex smortex left a comment

Choose a reason for hiding this comment

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

That looks good, see some minor in-line comments. I don't see merge conflicts but a rebase may help @LukasAud.

@@ -4,9 +4,9 @@

describe 'fqdn_rotate' do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
describe 'fqdn_rotate' do
describe 'stdlib::fqdn_rotate' do

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 was a deliberate choice to show that the shim does actually correctly invoke the namespaced function.


function_args = [value] + extra
scope.function_fqdn_rotate(function_args)
scope.call_function('fqdn_rotate', function_args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
scope.call_function('fqdn_rotate', function_args)
scope.call_function('stdlib::fqdn_rotate', function_args)

repeated_param 'Any', :args
end
def deprecation_gen(*args)
call_function('deprecation', 'fqdn_rotate', 'This method is deprecated, please use stdlib::fqdn_rotate instead.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

With your work on #1377, I think it makes sense to:

Suggested change
call_function('deprecation', 'fqdn_rotate', 'This method is deprecated, please use stdlib::fqdn_rotate instead.')
call_function('deprecation', 'fqdn_rotate', 'This method is deprecated, please use stdlib::fqdn_rotate instead.', false)

We may also open another PR to be merged when the next major version is released and that restore the failure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed whilst rebasing by rerunning script.

@ekohl ekohl mentioned this pull request Sep 15, 2023
2 tasks
@alexjfisher alexjfisher dismissed stale reviews from b4ldr and bastelfreak via 8190beb September 15, 2023 13:50
@alexjfisher
Copy link
Collaborator Author

Rebased to fix #1381

Convert the function to the modern function API as a namespaced function
and use the `networking` fact instead of legacy facts.

A non-namespaced shim is also created (but marked deprecated),
to preserve compatibility.

Fixes puppetlabs#1381
@alexjfisher alexjfisher merged commit 139f6e9 into puppetlabs:main Sep 15, 2023
43 checks passed
@alexjfisher alexjfisher deleted the modernise_fqdn_rotate branch September 15, 2023 14:57
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.

fqdn_rotate function output often changes since v9
8 participants