-
Notifications
You must be signed in to change notification settings - Fork 582
Make ensure_packages work with ensure => present
#1300
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
Merged
ekohl
merged 1 commit into
puppetlabs:main
from
alexjfisher:ensure_packages_improvements
Apr 23, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root cause of many problems is that
defined_with_params
doesn't understand this bit: https://github.com/puppetlabs/puppet/blob/523d881ecdee777d7bec46cea5b26fd6621f558c/lib/puppet/type/package.rb#L113-L114I was thinking about this too and wondering about teaching
defined_with_params
aboutaliasvalue
. Though I really wonder how you'd implement that, given a lot of those mechanics are private APIs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I did try and figure out a more generic solution, but also figured the less I touch, the less chance of subtly breaking anything!
This is effectively my 2nd PR on the way to fixing this issue. The first one was a while back and turned the function into a modern API version.
Whilst I'm not super happy with the hackiness of this solution, as a whole with the refactoring in this PR combined with the work done when moving from the old API I think the final result is still a lot nicer than what we originally had.
The breaking change in 8.0.0 has been a blocker for several people in upgrading stdlib, so hopefully this is a good enough fix and can be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also ran into it myself, so I think this would be good start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I drilled into this for a bit and got closer, but not completely there. I got stuck trying to figure out how to get a list of known aliases and couldn't get there in this context. What I'd like to do is update this check,
puppetlabs-stdlib/lib/puppet/parser/functions/defined_with_params.rb
Line 65 in b2ace0d
to do something smarter, like
res[key].aliases.include? value
instead of the straight equality check it does now.In other contexts, I can get a list of aliases using
Puppet::Parameter::Value.aliases
but I can't quite get there from here yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binford2k that's exactly what my line of thought was, except I gave up on figuring out the
.aliases
bit. As I said: those parts look like private APIs.