Skip to content

Convert data to Pcore before serialisation in to_ruby/to_python #1237

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
merged 2 commits into from
May 16, 2022

Conversation

smortex
Copy link
Collaborator

@smortex smortex commented Apr 26, 2022

This is a follow-up to #1205 to perform Pcore serialization and correctly handle all Any values.

This PR also include:

smortex added 2 commits April 26, 2022 11:31
:undef was used in old Puppet functions, but modern Puppet 4 functions
receive `undef` Puppet values as `nil` Ruby values.  This cause
to_python() to serialize `undef` as `nil` instead of `None`, which is
not valid Python code.

Fix the to_python() behavior by comparing with `nil`.  Update the test
suite accordingly.

While here, also adjust the to_ruby() function which had the same wrong
logic but was not causing trouble because in Ruby, we want to serialize
`nil` to `nil` :-)
This allow to pass any Puppet structure to the to_python and to_ruby
functions.
@smortex smortex requested a review from a team as a code owner April 26, 2022 21:38
@puppet-community-rangefinder
Copy link

to_python is a function

that may have no external impact to Forge modules.

to_ruby is a function

that may have no external impact to Forge modules.

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

@chelnak
Copy link
Contributor

chelnak commented Apr 26, 2022

Given that this PR contains #1205, are you happy to close it in favour of this? Or is there value in keeping it open?

@smortex
Copy link
Collaborator Author

smortex commented Apr 26, 2022

Given that this PR contains #1205, are you happy to close it in favour of this? Or is there value in keeping it open?

GitHub will automatically mark #1205 as merged when this one is merged as long as the commits are not rebased (so a merge commit will do the right thing). This helps when using tools such as github-changelog-generator 😉

@chelnak
Copy link
Contributor

chelnak commented Apr 27, 2022

Sounds good 👍

Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

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

Same as with the connected pr, this looks good to me :)

@david22swan david22swan merged commit f04feb8 into main May 16, 2022
@david22swan david22swan deleted the to_ruby-to_python-pcore branch May 16, 2022 12:31
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.

4 participants