Fix has_ip_address and has_ip_network functions#1448
Merged
bastelfreak merged 1 commit intopuppetlabs:mainfrom Mar 5, 2025
Merged
Fix has_ip_address and has_ip_network functions#1448bastelfreak merged 1 commit intopuppetlabs:mainfrom
has_ip_address and has_ip_network functions#1448bastelfreak merged 1 commit intopuppetlabs:mainfrom
Conversation
The functions were using the old legacy function API. This meant that when they called `has_interface_with`, they were calling the legacy implementation of that function and not the v4 API version introduced in bc218f0. Only in the v4 API implementation was the modern `networking` structured fact being used. The old `parser/functions/has_interface_with.rb` version still used legacy facts that are now not included in Puppet 8 by default. In this commit, we replace the `has_ip_address` and `has_ip_network` functions with namespaced Puppet language functions, (these functions are simple enough to not need ruby). Non-namespaced versions are added (but marked as deprecated) in `lib/puppet/functions`. The old implementations are removed completely. This is _almost_ certainly not going to be a breaking change for anyone. (Only other legacy functions which in turn call these functions could be affected). Fixes puppetlabs#1447
f2b8cbf to
2a25b6d
Compare
bastelfreak
reviewed
Feb 11, 2025
| @@ -0,0 +1,10 @@ | |||
| # @summary Returns true if the client has the requested IPv4 address on some interface. | |||
| # | |||
| # @param ip_address | |||
Collaborator
There was a problem hiding this comment.
Should we also support ipv6?
Collaborator
Author
There was a problem hiding this comment.
If someone wants to add that, they could open a PR for it. I did have a quick think about it, and I guess with IPv6 you'd want to do something a bit more sophisticated than just matching the string though as there are several ways to write the same address.
Collaborator
There was a problem hiding this comment.
Ah right, that would require updating stdlib::has_interface_with() to work with IpAddr objects
b4ldr
approved these changes
Feb 12, 2025
|
I think the acceptance test breaks due to puppetlabs/puppetlabs-puppet_agent#754. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The functions were using the old legacy function API. This meant that when they called
has_interface_with, they were calling the legacy implementation of that function and not the v4 API version introduced in bc218f0.Only in the v4 API implementation was the modern
networkingstructured fact being used. The oldparser/functions/has_interface_with.rbversion still used legacy facts that are now not included in Puppet 8 by default.In this commit, we replace the
has_ip_addressandhas_ip_networkfunctions with namespaced Puppet language functions, (these functions are simple enough to not need ruby). Non-namespaced versions are added (but marked as deprecated) inlib/puppet/functions.The old implementations are removed completely. This is almost certainly not going to be a breaking change for anyone. (Only other legacy functions which in turn call these functions could be affected).
Fixes #1447