Skip to content

New function to_python() / to_ruby() #1200

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
Aug 23, 2021
Merged

Conversation

smortex
Copy link
Collaborator

@smortex smortex commented Aug 16, 2021

Add two new utility functions to transform Puppet data structures into their corresponding representation in Python and Ruby.

These functions are aimed to help writing templates of Ruby / Python code when managing configuration files in these languages with Puppet. Quoting strings, managing undef can be a bit tedious:

EMAIL_USE_TLS = <%= String($taiga::back::email_use_tls, '%T') %>
EMAIL_HOST = <%= if $taiga::back::email_host { String($taiga::back::email_host, '%p') } else { 'None' } %>

These functions make this more readable:

EMAIL_USE_TLS = <%= $taiga::back::email_use_tls.to_python %>
EMAIL_HOST = <%= $taiga::back::email_host.to_python %>

This initial work took place in voxpupuli/puppet-python#616 but it was suggested to move the code in stdlib.

This function return a String representation of the value passed as
parameter in Python.
This function return a String representation of the value passed as
parameter in Ruby.
@smortex smortex requested a review from a team as a code owner August 16, 2021 19:08
@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 319 of 578 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.

Copy link
Collaborator

@bastelfreak bastelfreak left a comment

Choose a reason for hiding this comment

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

looks good to me / the windows failures don't look related to the change.

@david22swan
Copy link
Member

@smortex @bastelfreak
Windows failure seems to be a transient so gonna go ahead and merge.
Thanks for putting in the work, they seem like two pretty interesting functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants