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

Pass calling scope to stdlib::ensure_packages from shim #1366

Merged
merged 1 commit into from Jun 15, 2023

Conversation

alexjfisher
Copy link
Collaborator

@alexjfisher alexjfisher commented Jun 2, 2023

Make the ensure_packages shim an Internal function and pass scope to the namespaced version so as to not change the behaviour of where packages are contained.

When the function was first ported to the new API, it was discussed that the existing behaviour might not be 'correct', but changing it would be a breaking change that might have consequences for many users.

In namespacing the function in 9.0.0 we accidentally created a situation where the namespaced version worked as before, but the non-namespaced version, (the shim), now behaved differently.

Fixes #1374

bastelfreak
bastelfreak previously approved these changes Jun 2, 2023
@alexjfisher
Copy link
Collaborator Author

@bastelfreak Hold off on this. I should make sure it actually works first! (which it doesn't!)

@@ -1,14 +1,13 @@
# frozen_string_literal: true

# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims`

# @summary DEPRECATED. Use the namespaced function [`stdlib::ensure_packages`](#stdlibensure_packages) instead.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hum, maybe also change this line because it is what triggers the rake task that generated this code:
https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/Rakefile#L95

Suggested change
# @summary DEPRECATED. Use the namespaced function [`stdlib::ensure_packages`](#stdlibensure_packages) instead.
# @summary DEPRECATED. Use the scoped and namespaced function [`stdlib::ensure_packages`](#stdlibensure_packages) instead.

Very hackish :-/

Otherwise we can search for Puppet::Functions\.create_function\(.*, Puppet::Functions::InternalFunction\) and generate different code if we find it. Also a bit hackish.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's more an internal detail. Not sure we really need to spell it out to users. Just not break things for them! :)

Are we likely to be running the rake task anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@smortex Now that I've updated the rake task to ignore this file, I've just got what you were getting at!

@danielparks

This comment was marked as outdated.

@danielparks
Copy link

danielparks commented Jun 8, 2023

Ah, I misunderstood (based on this comment from alexjfisher). The only important part of my (now hidden) comment is that this doesn’t actually fix the main issue in #1365.

The commit message (or PR description? not sure if they’re both important) should probably be updated so it doesn’t close the issue.

@alexjfisher
Copy link
Collaborator Author

#1365 really should be two issues. The only bit that is ensure_packages specific is fixed by this change though?? Do you want to open a separate issue for whether the deprecate function should cause a compile failure when strict mode is on? That's always been the case, but I suspect has largely gone unnoticed before as it defaulted to off.

@robertc99
Copy link

I can't believe theres been a new release of stdlib and this didnt get included.. Its a serious bug.

@alexjfisher
Copy link
Collaborator Author

I can't believe theres been a new release of stdlib and this didnt get included.. Its a serious bug.

cc @chelnak

Make the `ensure_packages` shim an Internal function and pass scope to
the namespaced version so as to not change the behaviour of where
packages are contained.

When the function was first ported to the new API, it was discussed that
the existing behaviour might not be 'correct', but changing it would be
a breaking change that might have consequences for many users.

In namespacing the function in 9.0.0 we accidentally created a situation
where the namespaced version worked as before, but the non-namespaced
version, (the shim), now behaved differently.

Fixes puppetlabs#1374
@jordanbreen28
Copy link
Contributor

@alexjfisher Great catch, This looks good to me!
Can you @ me directly when this is ready to be be merged.

@alexjfisher
Copy link
Collaborator Author

#1365 really should be two issues.

I've split the original issue into #1374 and #1373 and updated this PRs commit and description to reference #1374

@alexjfisher
Copy link
Collaborator Author

@jordanbreen28 Should be good now I think.

Copy link
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

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

Thanks again @alexjfisher!
Will merge on green tests

@jordanbreen28 jordanbreen28 merged commit 3df8f0c into puppetlabs:main Jun 15, 2023
44 checks passed
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.

Non namespaced ensure_packages function behaviour changed in 9.0.0
7 participants